Re: Cocoa class extension best practice
Re: Cocoa class extension best practice
- Subject: Re: Cocoa class extension best practice
- From: Steve Mills <email@hidden>
- Date: Wed, 16 Oct 2013 13:09:48 -0500
On Oct 16, 2013, at 12:45:49, Andy Lee <email@hidden> wrote:
> I still don't see what mutability has to do with it, but that's a side issue.
The mutability doesn't matter. I'm just emphasizing that the internal array is mutable and this is returning a COPY of that array (which happens to be immutable).
> I would too.
>
> I suspect you can safely use the instance variable, but if you're concerned about the fact that it's undocumented, or that Apple could in theory move it to the @implementation so that it's no longer visible to your code, you can accomplish the same using numberOfItems and itemAtIndex:, as I mentioned earlier. Then you're using totally public API *and* this particular method no longer instantiates any objects. Either way, I'd add a clarifying comment.
That's a good point. I'm guessing the author of this code used itemArray simply because it was an easy way to use the new "in" for loop mechanism.
--
Steve Mills
office: 952-818-3871
home: 952-401-6255
cell: 612-803-6157
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden