0

I'm trying to pass data back with the segue, and am following this answer: How to Pass information Back in iOS when reversing a Segue?

However when I try to put this line in:

@property (nonatomic) id<MyDataDelegate> delegate;

I get the following warning:

enter image description here

And when I try to put to the first view controller like this:

@interface ContainerViewController : UIViewController <MyDataDelegate>

I get the error "Cannot find protocol declaration for 'MyDataDelegate' " and I did include the other header file...

Community
  • 1
  • 1
nonuma
  • 399
  • 1
  • 3
  • 14

1 Answers1

4

From the error message it looks like you are adding the property to a subclass of UIPageViewController. But UIPageViewController already has a delegate property of a different type.

You therefore need to either rename your property to something else, or declare MyDataDelegate to conform to UIPageViewControllerDelegate so that your property redeclaration is compatible with the base class version:

@protocol MyDataDelegate <UIPageViewControllerDelegate>

...

@end

You also need to declare your property with the weak attribute.

Mike Weller
  • 45,401
  • 15
  • 131
  • 151
  • This indeed fixes the warning, but when I add @interface ContainerViewController : UIViewController I still get the error like I said in my question – nonuma Apr 29 '13 at 10:16
  • 1
    @nonuma If your delegate header file is also including the controller header, you have a cyclical dependency. Make sure your protocol doesn't include the controller's header (forward declaration `@class ...` may be necessary). – Sulthan Apr 29 '13 at 10:21
  • @Mike Weller I did everything now from the link I said before, and now I'm stuck here: PageScrollViewController.delegate = self; the compiler tells me he couldn't found the property on the object of type PageScrollViewController...but I did add it as property? – nonuma Apr 29 '13 at 11:26