55 lines · plain
1#import <Foundation/Foundation.h>2#import "InternalDefiner.h"3 4@interface Container : NSObject {5@public6 InternalDefiner *_definer;7}8 9-(id)init;10@end11 12@implementation Container13 14-(id)init15{16 if (self = [super init])17 {18 _definer = [[InternalDefiner alloc] initWithFoo:4 andBar:5];19 }20 return self;21}22 23@end24 25@interface InheritContainer : InternalDefiner 26@property (nonatomic, strong) NSMutableArray *filteredDataSource;27-(id)init;28@end29 30@implementation InheritContainer31 32-(id)init33{34 if (self = [super initWithFoo:2 andBar:3])35 {36 self.filteredDataSource = [NSMutableArray arrayWithObjects:@"hello", @"world", nil];37 }38 return self;39}40 41@end42 43int main(int argc, const char * argv[])44{45 @autoreleasepool {46 Container *j = [[Container alloc] init];47 InheritContainer *k = [[InheritContainer alloc] init];48 49 printf("ivar value = %u\n", (unsigned)j->_definer->foo); // breakpoint150 printf("ivar value = %u\n", (unsigned)k->foo);51 } 52 return 0;53}54 55