FROM : Bill Bumgarner
DATE : Sun Jan 06 03:16:50 2008
On Jan 5, 2008, at 5:53 PM, Bill Bumgarner wrote:
>>
>> Which argument to the @property directive would give the same as
>>
>> - (void)setContent:(NSArray *)newArray;
>> {
>> if(content != newArray) {
>> [content release];
>> content = [[NSMutableArray alloc] initWithArray:newArray];
>> }
>> }
>
> Which, unfortunately, is the alternative. There is an enhancement
> request already to offer a mutablecopy keyword.
I should add, though, that the above is not really atomic (and, of
course, "atomic" is not thread safe -- merely non-crashy in the face
of the threads).
(One of the advantages of GC is that simple setters like the above
become atomic in that assignments are atomic for object types.)
b.bum
DATE : Sun Jan 06 03:16:50 2008
On Jan 5, 2008, at 5:53 PM, Bill Bumgarner wrote:
>>
>> Which argument to the @property directive would give the same as
>>
>> - (void)setContent:(NSArray *)newArray;
>> {
>> if(content != newArray) {
>> [content release];
>> content = [[NSMutableArray alloc] initWithArray:newArray];
>> }
>> }
>
> Which, unfortunately, is the alternative. There is an enhancement
> request already to offer a mutablecopy keyword.
I should add, though, that the above is not really atomic (and, of
course, "atomic" is not thread safe -- merely non-crashy in the face
of the threads).
(One of the advantages of GC is that simple setters like the above
become atomic in that assignments are atomic for object types.)
b.bum






Cocoa mail archive

