Stuck when passing data back with segue
ios, iphone, objective-c
Solution
You're trying to call an instance method (`[PageScrollViewController setDelegate:]`) on an object of type `Class` (in this case, `PageScrollViewController`).
Try this:
Replace
PageScrollViewController *secondViewController = segue.destinationViewController;
if ([PageScrollViewController isKindOfClass:[PageScrollViewController class]]) {
PageScrollViewController.delegate = self;
}
With
PageScrollViewController *secondViewController = segue.destinationViewController;
if ([secondViewController isKindOfClass:[PageScrollViewController class]]) {
secondViewController.delegate = self;
}
Problem
I'm trying to pass data back with the segue using protocols. I'm following this answer: How to Pass information Back in iOS when reversing a Segue? So what I already did: PageScrollViewController.h ``` @protocol MyDataDelegate <NSObject, UIPageViewControllerDelegate> - (void)recieveData:(NSString *)theData; @end ``` and I also added the property: ``` @property (nonatomic,weak) id<MyDataDelegate> delegate; ``` ContainerViewController.h ``` #import "PageScrollViewController.h" @interface ContainerViewController : UIViewController <MyDataDelegate> //... ``` ContainerViewController.m ``` - (void)recieveData:(NSString *)theData { //Do something with data here } ``` and here I'm stuck: ``` - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { //Get a handle on the view controller about be presented PageScrollViewController *secondViewController = segue.destinationViewController; if ([PageScrollViewController isKindOfClass:[PageScrollViewController class]]) { PageScrollViewController.delegate = self; } } ``` The line `PageScrollViewController.delegate = self;` gives an error: Property 'delegate' not found on object of type 'PageScrollViewController' but I did add it as a property and synthesized it...