I’d like to find out where a delegate specified exclusively as a property in a particular WWDC Live Demo Video is declared (Note: You’ll need an Apple Developer login to access the video).
The relevant code is listed below, omitting an iOS 5 property qualifier for NDA reasons. I believe this qualifier has no relevance for my query.
#import <UIKit/UIKit.h>
@class NSManagedObject;
@protocol CoffeeViewControllerDelegate;
@interface CoffeeViewController : UITableViewController
@property (_____,nonatomic) id <CoffeeViewControllerDelegate> delegate;
@end
@protocol CoffeeViewControllerDelegate <NSObject>
// ...
@end
My questions are:
- Where is the delegate declared as a class member?
- Does the inheritance of the
NSObjectprotocol by theCoffeeViewControllerDelegateprotocol mean that runtime checking that the delegate has allNSObjectmethods will occur? - Why is it necessary to forward declare
NSManagedObject? Is this a common requirement when utilizing Core Data?
Many thanks for your time.
@synthesizethe property (I’m not 100% sure about this)#import <CoreData/CoreData.h>but your code will compile more quickly just doing the forward declaration. Basically, it doesn’t need to know anything about the implementation other than the size of it (it’s an object so it’s a pointer)