Re: Accessing array in thread safe way
Re: Accessing array in thread safe way
- Subject: Re: Accessing array in thread safe way
- From: Charles Srstka <email@hidden>
- Date: Thu, 08 Mar 2012 14:32:41 -0600
On Mar 8, 2012, at 2:18 PM, CoGe - Tamas Nagy wrote:
> I should subclass NSMutableArray because I had a project which used NSMutableArray (calls) before, but was not thread safe. Anyway, I can't really understand why it would be _really_ better to implement just accessors, but maybe you could explain it a bit more?
Same reason you wouldn’t implement a “name” property as a NSMutableString — encapsulation, an important concept in object-oriented programming. Your object should be the only object that directly manipulates its internal data. You end up with a much more flexible design this way, for a lot of the reasons I already mentioned.
Charles
_______________________________________________
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