• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Changing the model behind contoller's back?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Changing the model behind contoller's back?
      • From: "Oleg Krupnov" <email@hidden>
References: 
 >Changing the model behind contoller's back? (From: "Oleg Krupnov" <email@hidden>)

  • Prev by Date: Re: string convertion: converting getter name to setter
  • Next by Date: Re: string convertion: converting getter name to setter
  • Previous by thread: Changing the model behind contoller's back?
  • Next by thread: Re: Changing the model behind contoller's back?
  • Index(es):
    • Date
    • Thread