Skip to content

Instantly share code, notes, and snippets.

@nevyn
Created September 10, 2013 08:34
Show Gist options
  • Save nevyn/6506590 to your computer and use it in GitHub Desktop.
Save nevyn/6506590 to your computer and use it in GitHub Desktop.
ivar namespacing in objc
#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