At 8:04 -0800 26/2/09, mmalc Crawford wrote:
On Feb 26, 2009, at 6:10 AM, Peter N Lewis wrote:

The next issue (and this is almost certainly where your problem is) is that your @property is set to copy, so:
[self.currentStates addObject:@"hello"];
is equivalent:
[[self currentStates] addObject:@"hello"];
And [self currentStates] returns a copy of the NSMutableArray. And so you create a copy, then you add the string, then it is autoreleased.

No, this is wrong.
'copy' applies to the setter, not getter.
<http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_5_section_3.html#//apple_ref/doc/uid/TP30001163-CH17-SW2>

Yeah, I thought I was screwing up some reasoning on that one.

But

@property (nonatomic, copy) NSMutableArray *currentStates;

Does do a non mutable copy, right?  So:

@synthesize currentStates;

self.currentStates = [NSMutableArray array];

will end up with currentStates being an instance of NSArray, which is not helpful.

So is it correct that it never makes sense to have:

@property (nonatomic, copy) NSMutableANYTHING *ivar;

Thanks,
   Peter.

--
     Run macros from your iPhone with Keyboard Maestro Control!
       or take a break with Aragom Space War for your iPhone

Keyboard Maestro <http://www.keyboardmaestro.com/> Macros for your Mac
Aragom Space War <http://www.stairways.com/iphone/aragom> Don't get killed!
<http://www.stairways.com/>           <http://download.stairways.com/>
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to