Re: Changing the model behind contoller's back?
Re: Changing the model behind contoller's back?
- Subject: Re: Changing the model behind contoller's back?
- From: Rob Keniger <email@hidden>
- Date: Fri, 5 Sep 2008 11:53:01 +1000
On 04/09/2008, at 9:52 PM, Oleg Krupnov wrote:
The question is: am I allowed to alter the model directly, or should I
always use the controller?
You can change the model directly, but you must use KVC-compliant
methods to do so, unless you fire -willChangeValueForKey and -
didChangeValueForKey in your custom method.
Normally you would use indexed accessor methods for collection types,
e.g.:
- (unsigned int)countOfFoo;
- (id)objectInFooAtIndex:(unsigned int)index;
- (void)insertObject:(id)anObject inFooAtIndex:(unsigned int)index;
- (void)removeObjectFromFooAtIndex:(unsigned int)index;
- (void)replaceObjectInFooAtIndex:(unsigned int)index withObject:
(id)anObject;
Have a look here:
http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/AccessorConventions.html#/
/apple_ref/doc/uid/20002174
--
Rob Keniger
_______________________________________________
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