Hi, everyone.
I have working for iPhone development for a while. First time, I so surprised with memory-management in objective-c :). but now I got it a little bit.
The question is, sometime, I use protocol as an attribute of a class, because I think its definition very similar to 'interface' in C# or Java. like below.
@protocol Shield
...
@end
// Interface
@interface Dragon {
id<Shield> shield
NSString * name;
}
@property (nonatomic,retain) id<Shield> shield;
@property (nonatomic,retain) NSString * name;
@end
but I alway release any attribute object in dealloc() method. like below.
-(void)dealloc {
[name release];
[shield release]; // <--- Totally impossible. xcode said '-release not found in protocol'
[super dealloc];
}
As you see, I couldn't release the protocol. So would this cause me future memory issue? Do you have another way to handle this solution to advice me?