Possible Duplicate:
delegate not being called
I declared a delegate in my appdelegate class, so it looks like:
@protocol LoginDelegate
- (void) loadData:(NSObject *)viewCon;
@end
@class RootViewController;
@class DetailViewController;
@interface TestAppDelegate : NSObject <UIApplicationDelegate, LoginViewControllerDelegate, RKObjectLoaderDelegate> {
id <LoginDelegate> delegate;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UISplitViewController *splitViewController;
@property (nonatomic, retain) IBOutlet RootViewController *rootViewController;
@property (nonatomic, retain) IBOutlet DetailViewController *detailViewController;
@property (nonatomic, assign) id <LoginDelegate> delegate;
@end
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//some code
[self.delegate loadData:self];
//some code
return YES;
}
In my other class then I implement this delegate:
- (void) loadData:(NSObject*)viewCon
{
NSLog(@"LOADING DATA");
[[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"/groups.json" delegate: self];
}
However, why is it not getting called?
It is not getting called, because you dont set something as delegate (I assume).
So self.delegate is nil, and as u can send any message to nil, nothings happens
Do you have
((TestAppDelegate *)[[UIApplication sharedApplication]).delegate = selfor((TestAppDelegate *)[[UIApplication sharedApplication]).delegate = aObjectsomewhere, whereselforaObjectconforms to yourLoginDelegate?See: Delegation and Protocols