views:

25

answers:

2

Ok, I've spend like half day on this and it's killing me.

So I've got 3 view controllers transitioning from one another, something like this:

I call the UploadDecisionViewController after destroying the previous View Controller:

[self dismissModalViewControllerAnimated:YES];
[self performSelector:@selector(showUDModalView) withObject:nil afterDelay:0.5];

In my showUDModalView method:

- (void)showUDModalView
{
    UploadDecisionViewController *udcontroller = [[UploadDecisionViewController alloc] initWithNibName:@"UploadDecisionViewController" bundle:nil];
    udcontroller.delegate = self;

    [self presentModalViewController:udcontroller animated:YES];
    [udcontroller release];

}

The UploadDecisionViewController shows up no problem. The UploadDecisionViewController has a button, which when clicked I want it to transition to the FileUploadViewController. I setup a UploadDecisionDelegate, threw a method in there to handle the button clicking:

Inside UploadDecisionDelegate protocol (UploadDecisionViewController.h):

@protocol UploadDecisionDelegate

//let UOnliveViewController know that a button was selected
- (void)UploadDecisionViewController:(UploadDecisionViewController *)controller madeChoice:(NSString *)whichDirection;
@end

Then inside my IBAction method when the button is clicked, I have this:

- (IBAction)decisionSelected:(id)sender
{

    [delegate UploadDecisionViewController:self madeChoice:@"upload"];//crashing at this line

}

When I run this, at this line above it is throwing a runtime exception:

2010-06-09 12:48:59.561 UOnlive[4735:207] *** -[UIView UploadDecisionViewController:madeChoice:]: unrecognized selector sent to instance 0x3b65420
2010-06-09 12:48:59.562 UOnlive[4735:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIView UploadDecisionViewController:madeChoice:]: unrecognized selector sent to instance 0x3b65420'
2010-06-09 12:48:59.563 UOnlive[4735:207] Stack: (
    33502299,
    2495698185,
    33884219,
    33453686,
    33306306,
    20618,
    2982917,
    3390286,
    3399023,
    3394235,
    3087839,
    2996168,
    3022945,
    40156505,
    33287040,
    33283144,
    40150549,
    40150746,
    3026863,
    11700,
    11554
)

Let me throw in the delegate method implemented also:

- (void)UploadDecisionViewController:(UploadDecisionViewController *)controller madeChoice:(NSString *)whichDirection
{
    NSLog(@"it got to here 245");
    [self dismissModalViewControllerAnimated:YES];
    if (yesOrNo) {
        //open up the FileUploadViewController and proceed to upload
        [self performSelector:@selector(showFUModalView) withObject:nil afterDelay:0.5];

    }
}

Can someone tell me what the heck is going on? Thanks a bunch for the help...

A: 

Your code is to lengthy and I dont want to go through this but just an advice, you can c if your object can/cannot perform a selector with this kind of statement:

if([myObj respondsToSelector:@selector(myFunc)])
{
 //do something
}
else{
//do something else
}
jAmi
Sorry, I was just trying to be comprehensive. In a nutshell, the error is thrown when in the method where the button is linked to call another viewcontroller, I want to throw the control back to the main view controller by calling the delegate function but it is erroring in that call. Hope that makes it clear.
chimgrrl
A: 

The error says that you are trying to call the UploadDecisionViewController method on UIView.

My bet is that you set some view to the delegate instead of view controller.

Where the showUDModalView method is located?
Maybe you set the delegate in some additional places?

Michael Kessler
Yup, that was my problem. Thanks for help :) I set the delegate to the view in the nibs... :)
chimgrrl