Re: Problems with KVC
Re: Problems with KVC
- Subject: Re: Problems with KVC
- From: "C.W. Betts" <email@hidden>
- Date: Fri, 23 Nov 2012 22:16:35 -0700
On Nov 23, 2012, at 9:57 PM, Quincey Morris <email@hidden> wrote:
> On Nov 23, 2012, at 20:18 , "C.W. Betts" <email@hidden> wrote:
>
>> I'm trying to get my program PlayerPRO Cocoa to display the contents of the music list. I was able to put things into the list, but they do not show up in the table view.
>> (Full code is available at sourceforge.net/projects/playerpro, on the PlayerPRO6 branch)
>>
>> I have it set up so that the App Delegate has a reference to the PPMusicList class defined as musicList. PPMusicList has a mutable array with contents of PPMusicListObject; the PPMusicListObject has two values: an NSURL that has the full path of a file (musicUrl), and the file's name (fileName). the PPMusicList class that has the following defines:
>>
>> - (NSUInteger)countOfMusicList;
>> - (id)objectInMusicListAtIndex:(NSUInteger)idx;
>> - (void)insertObject:(id)anObj inMusicListAtIndex:(NSUInteger)idx;
>> - (void)removeObjectInMusicListAtIndex:(NSUInteger)object;
>> - (void)replaceObjectInMusicListAtIndex:(NSUInteger)index withObject:(id)anObject;
>>
>> There is an Array controller bound to the app delegate with the model key path set to musicList and the table is bound to the array controller with the model key path set to fileName.
>>
>> What am I doing wrong?
>
> Your app delegate isn't KVO compliant for the "musicList" property. The PPMusicList class isn't KVO compliant for the "musicList" property. In both cases, you're altering an ivar (or the array pointed to by an ivar) directly, so there are going to be no KVO notifications and bindings aren't going to work.
Thank you. I'll look into implementing KVO.
>
> You realize, don't you, that your array of PPMusicListObject instances is appDelegate.musicList.musicList? That means your array controller requires a key path of "musicList.musicList" too.
I thought that might be an issue. Thanks for confirming it.
>
>
_______________________________________________
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