It depends on your type of property. If you set prop1 as Retain / Copy, you should write like this:
@property (nonatomic, retain) id prop1; if(self.prop1 == nil) { SomeClass *obj = [[SomeClass alloc] init]; self.prop1 = obj; [obj release]; }
if you install prop1 as Assign then
@property (nonatomic, assign) id prop1; if(self.prop1 == nil) { SomeClass *obj = [[SomeClass alloc] init]; self.prop1 = [obj retain]; [obj release]; }
In dealloc you must pass prop1, for example.
- (void)dealloc { [prop1 release]; [super dealloc]; }
If you want to play in safe mode with multiple streams, you can choose one of the following options:
1. Make property atomic 2. Use @synchronized over prop1 3. Use Mutex Lock
source share