Created
September 10, 2013 08:34
-
-
Save nevyn/6506590 to your computer and use it in GitHub Desktop.
ivar namespacing in objc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@interface Foo : NSObject | |
@end | |
@implementation Foo { | |
int _foo; | |
} | |
- (id)init | |
{ | |
_foo = 1; | |
return self; | |
} | |
- (int)foo1 | |
{ | |
return _foo; | |
} | |
@end | |
@interface Bar : Foo | |
@end | |
@implementation Bar { | |
int _foo; | |
} | |
- (id)init | |
{ | |
[super init]; | |
_foo = 2; | |
return self; | |
} | |
- (int)foo2 | |
{ | |
return _foo; | |
} | |
@end | |
int main(int argc, const char * argv[]) | |
{ | |
@autoreleasepool { | |
Bar *foo = [[Bar new] autorelease]; | |
// insert code here... | |
NSLog(@"Hello, World! %d %d", [foo foo1], [foo foo2]); | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment