Skip to content

Instantly share code, notes, and snippets.

@jdelStrother
Created May 23, 2012 16:55
Show Gist options
  • Select an option

  • Save jdelStrother/2776348 to your computer and use it in GitHub Desktop.

Select an option

Save jdelStrother/2776348 to your computer and use it in GitHub Desktop.
@protocol NamedObject <NSObject>
-(NSString*)name;
@end
/////////////////
@interface User : NSObject
-(NSString*)name;
@end
/////////////////
@interface Greeter : NSObject
@end
@implementation Greeter
-(id)init {
if (self=[super init]) {
User* user=[[User alloc] init];
[self sayHi:user];
}
return self;
}
-(void)sayHi:(id<NamedObject>)object {
NSLog(@"Hi %@", object.name);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment