Skip to content

Instantly share code, notes, and snippets.

@billburgess
Created April 19, 2013 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billburgess/5423187 to your computer and use it in GitHub Desktop.
Save billburgess/5423187 to your computer and use it in GitHub Desktop.
Setting Class method delegates
MyClass.h
#import "AnotherClass.h"
@interface MyClass : NSObject <AnotherClassDelegate>
+(void)myMethod;
MyClass.m
+(void)myMethod {
AnotherClass *foo = [[AnotherClass alloc] initWithDelegate:(id<AnotherClassDelegate>)self];
[foo anotherMethod];
}
-(void)delegateCallback {
// want this to be called
}
@nfarina
Copy link

nfarina commented Apr 19, 2013

Shouldn't it be +(void)delegateCallback?

@billburgess
Copy link
Author

That is what I ended up doing and it worked. +1 for @nfarina

You can get an extra point for explaining why. The delegate methods are defined in AnotherClass as -(void). Is it just because only class methods can see other class methods? #noobstick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment