.
, , @interface, -dealloc. , , , @property.
temp , ObjC temp , .
a -release nil , [ temp release] . -op. temp non-nil -dealloc,, [temp release] .
, temp non-nil , -init , . -init, , , .
: -init. , , temp ivar , -initWithImage:
:
@implementation MyClass
...
- (id) init {
self = [super init];
if (self != nil) {
}
return self;
}
- (void) dealloc {
...
}
@end
, , - :
@implementation MyClass
...
- (id) initWithImage:(UIImage *)newImage {
self = [super init];
if (self != nil) {
temp = [newImage retain];
}
return self;
}
- (id) init {
return [self initWithImage:[UIImage imageNamed:@"foobar"]];
}
- (void) dealloc {
...
}
@end
-initWithImage: . , -init, -initWithImage:.
, . , -init . . . ( ) .
, . , -init -dealloc, - .
dealloc . , . .
ivars. . , . .
JeremyP Link to Cocoa Conceptual object documentation is good. You should definitely read the "Objects" sections and periodically re-read them, as you gain more experience, write your own custom classes. In the end, all of this will start to make sense.