1

Error tells me that "No '-setRosterForBoat:' method found".

What I am doing is attempting to pass an array backwards through the Navigation Controller stack that i have.

In the viewContoller that I am attempting to pass the array to I have it set up in the .h like so:

NSArray *rosterForBoat;
@property(nonatomic, retain) NSArray *rosterForBoat;

But the program runs fine and the array gets set with the proper objects. Should I hate to just ignore this, does anyone have any suggestions?

   CoCoachAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];

   NSArray *arr = [[NSArray alloc] initWithArray:appDelegate.boatNavController.viewControllers];

   [appDelegate.boatNavController popToViewController:[arr objectAtIndex:1] animated:YES];

   [[arr objectAtIndex:1] setRosterForBoat:tempRowers];

2 Answers 2

4

Since you are using the rosterForBoat array as property, I would synthesize it and set it the following way:

CoCoachAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
NSArray *arr = [[NSArray alloc] initWithArray:appDelegate.boatNavController.viewControllers];

ViewController *view_controller = [arr objectAtIndex:1];
[appDelegate.boatNavController popToViewController:view_controller animated:YES];

view_controller.rosterForBoat = tempRowers;

Hope this helps...

Sign up to request clarification or add additional context in comments.

Comments

3

The issue is that NSArray doesn't define a type like other language's arrays. So, when you use objectAtIndex:, it comes back at the generic 'id' type.

If you want to make the warning go away, do something like:

    YourViewController * controller = [arr objectAtIndex: 1];
    [controller setRosterForBoat: tempRowers];

And make sure that you define setRosterForBoat: in your view controller's .h file.

Edit: And to answer your other question: it works because Objective-C uses message passing to communicate between instances. At compile time, XCode can't find Class->Method relationship between 'id' and setRosterForBoat:, but during runtime, because that method happens to exist for your view controller, everything works swimmingly.

1 Comment

nice addition to my solution...+1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.