Skip to content

Instantly share code, notes, and snippets.

@juniovitorino
Last active December 12, 2015 05:28
Show Gist options
  • Save juniovitorino/4722167 to your computer and use it in GitHub Desktop.
Save juniovitorino/4722167 to your computer and use it in GitHub Desktop.
Invoking class methods
@interface Person : NSObject
+(BOOL) walking;
@end
@interface Philip : Person
+(BOOL) walking;
@end
@implementation Philip
+(BOOL) walking
{
NSLog(@"Who are walking?");
return YES;
}
// And in some use case you can
// This way it use Person walk version
if([Person walking]) NSLog(@"A person is walking");
// This way if Philip implement walk your version is called
// If not the inherited version is called
if([[self class] walk]) NSLog(@"Philip is walking");
@end
@futur
Copy link

futur commented Feb 7, 2013

Thats super.. thanks a lot.. [self class] walk] makes the code even safer. :)

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