What is a modern runtime?

Note. . Typically, in a method, deallocyou should immediately release the instance variables of the object (instead of calling the access set and passing the nilas parameter), as shown in this example:

- (void)dealloc {
    [property release];
    [super dealloc];
}

If you use a modern runtime and synthesize an instance variable, you cannot directly access the instance variable, so you must call the access method:

- (void)dealloc {
    [self setProperty:nil];
    [super dealloc];
}

What is a modern runtime in iOS application development?

+5
source share
1 answer

ivar , . @synthesize ivar , , , ivar . . "Runtime Difference" " " Objective-C. , , ivar: @synthesize coffee=tea; - tea - ivar coffee.

ivar, , , . :

@interface Grisby : NSObject {}
@property (retain) NSObject * obj;
@end

@implementation Grisby

@synthesize obj;

- (void) dealloc {
    [obj release], obj = nil;
    [super dealloc];
}

- (id) init {
    self = [super init];
    if( !self ) return nil;

    obj = [NSObject new];

    return self;
}

- (NSObject *) obj {
    return [[obj retain] autorelease];
}

@end

" " ​​ Mac OS X 10.5 (Leopard) 64- . iOS . , .

" " Objective-C, , " ". ivar , , . , -, . , Mike Ash 2009 runtime writeup, Bavarious SO ivar.

, , , "Mac OS X Version 10.5 Delta" Objective-C .

+10

All Articles