• 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: Key Value Observing of NSMutableArray inside an object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Key Value Observing of NSMutableArray inside an object


  • Subject: Re: Key Value Observing of NSMutableArray inside an object
  • From: R <email@hidden>
  • Date: Sat, 28 Jan 2012 19:53:50 -0800 (PST)

More appropriate:

- (void)addDataObject:(DataObject *)theDataObject
{
    NSMutableArray *dataObjectArrayKVC=[self
mutableArrayValueForKey:@"dataObjectArray"];
    [dataObjectArrayKVC addObject:theDataObject];
}

On Jan 28, 8:19 pm, R <email@hidden> wrote:
> Mikael,
>
> I think all you need is:
>
> - (void)addDataObject:(DataObject *)theDataObject
> {
>     dataObjectArrayKVC=[self
> mutableArrayValueForKey:@"dataObjectArray"];
>     [dataObjectArrayKVC addObject:theDataObject];
>
> }
>
> dataObjectArrayKVC is a proxy for dataObjectArray.  Objects added/
> removed to/from dataObjectArrayKVC will be sent directly to
> dataObjectArray and your array controller will be alerted.  This is
> the same as feeding your objects through your array controller.
>
> On Jan 28, 2:28 pm, Mikael Wämundson <email@hidden> wrote:
>
>
>
>
>
>
>
>
>
> > Hi,
>
> > Background:
>
> > I have put an NSMutableArray (dataObjectArray) in my class DataObjectCollection. I have also made it possible to add objects to DataObjectCollection and hence the array by implementing
> > - (void)addDataObject:(DataObject *)theDataObject
> > {
> >     NSIndexSet *loneIndex = [NSIndexSet indexSetWithIndex:[[self dataObjectArray] count]];
> >     [self willChange:NSKeyValueChangeInsertion valuesAtIndexes:loneIndex forKey:@"dataObjectArray"];
> >     [dataObjectArray addObject:theDataObject];
> >     [self didChange:NSKeyValueChangeInsertion valuesAtIndexes:loneIndex forKey:@"dataObjectArray"];
>
> > }
>
> > In InterfaceBuilder I have put an ArrayController with ContentArray bound to "myAppDelegate".theDataObjectCollection.dataObjectArray
> > I have created bindings between the ArrayController and the columns of an NSTableView is
>
> > Problem:
> > Programmatically adding objects to my DataObjectCollection is not observed by the ArrayController.
>
> > I earlier had the dataObjectArray directly in my AppDelegate and then the key value observing worked.
>
> > Is there something I need to do with my class DataObjectCollection to make the observing work, i.e. to make it KVO compliant?
>
> > Thanks!
> > /Mikael
> > _______________________________________________
>
> > 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
>
>
> > This email sent to email@hidden
>
> _______________________________________________
>
> 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
>
>
> This email sent to email@hidden

_______________________________________________

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


References: 
 >Key Value Observing of NSMutableArray inside an object (From: Mikael Wämundson <email@hidden>)
 >Re: Key Value Observing of NSMutableArray inside an object (From: R <email@hidden>)

  • Prev by Date: Re: Key Value Observing of NSMutableArray inside an object
  • Next by Date: getting a nsurl file size
  • Previous by thread: Re: Key Value Observing of NSMutableArray inside an object
  • Next by thread: Is NSRuleEditor worth the learning curve?
  • Index(es):
    • Date
    • Thread