Re: Re: Cocoa Bindings Question(s)
Re: Re: Cocoa Bindings Question(s)
- Subject: Re: Re: Cocoa Bindings Question(s)
- From: <email@hidden>
- Date: Fri, 16 Jul 2004 20:51:03 -0400
>
From: Mont Rothstein <email@hidden>
>
Date: 2004/07/16 Fri PM 07:23:55 EDT
>
To: <email@hidden>, <email@hidden>
>
Subject: Re: Cocoa Bindings Question(s)
>
>
> countOfBookmarksArray:
>
> objectInBookmarksArrayAtIndex:
>
> insertObject:inBookmarksArrayAtIndex:
>
> removeObjectFromBookmarksArrayAtIndex:
>
> replaceObjectInBookmarksArrayAtIndex:
>
>
Those methods are Key-Value Coding accessor methods. There is a default
>
implementation in NSObject, so your frequently don't have to implement
them.
>
>
You can implement them if you want to modify the behavior of one of them
or
>
if the attribute isn't actually an array, but you want it to be treated as
>
such.
Thanks. Makes sense. I guess I was just wondering why he was using the
items just to insert and/or remove items. It looks like the routines are just
doing the default action. As to why mine wasn't called earlier, I still have no
idea. (He also uses these routines in the GraphicsBinding demo)
I just tried to re-do the same thing to another copy of the demo code (on
another system at home). I'm pretty sure I made the same changes and it
compiles fine, but when I run it, I'm getting an error in the log when I click
the Add button:
2004-07-16 20:48:15.089 Bibliotecha[2412] ***
-[NSKeyValueSlowMutableArray insertObject:atIndex:]: value for key booksList
of object 0x32d650 is nil
The error is actually being generated in the get accessor for my array:
- (NSMutableArray *)booksList
{
return booksList;
}
I've rechecked all the bindings and connections but I have no idea.
I even went to far as to put those additional routines in. It doesn't show that
error but nothing happens, I don't get a new row in the table.
I've stared at this for a couple hours now and I'm lost. Any ideas?
Thanks again.
jt
>
> I do see where some of these routines are called from his subclass of the
>
> NSArrayController (DNDArrayController) (in response to some drag and
drop
>
> routines), but the insertObject routine is called when the Add button is
>
> clicked, and I'm not sure why! I tried adding a similar call to the (Mike
>
> Beam) sample, but it's not called when I click it's Add button.
>
>
Add causes a call of the insertObject:inBookmarksArrayAtIndex: method
>
because the Bookmarks array is bound to the array controller. When the
Add
>
button tells the array controller to insert an object the binding inserts on
>
object (via KVC) in the bookmarks array.
>
>
I'm not sure why the method you added isn't called but I believe you have
to
>
implement all of the accessor method for an array if you implement any of
>
them.
>
>
I hope that helps.
>
>
-Mont
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.