Re: Bindings Concept Question
Re: Bindings Concept Question
- Subject: Re: Bindings Concept Question
- From: "Alex Wait" <email@hidden>
- Date: Sat, 21 Jun 2008 10:49:26 -0700
Ok. Pretty deep topic and I'm working to wrap my head around it.
I have taken the liberty to paste my addData method that is called when the
button is pressed (it's at the end of the message).
I have tried to, in my init method, to do this
id proxy = [controller mutableArrayValueForKey:@"arrayOfData"];
I have also tried using the values "firstName" and "lastName" which are the
properties of my Data class. controller is a pointer
to my array controller.
however proxy is nil. In a reponse, I read that
"KVO does provide the -mutableArrayValueForKey... methods to create a proxy
object which you can treat as a mutable array but which messages the owning
object to carry out the actual modifications. In that way, the owning
object is able to send out KVO notifications as necessary. (Even if the
proxy ends up accessing the ivar directly, it still messages the owning
object with -will/didChange:valuesAtIndexes
>
> :forKey:.)"
If I am able to get a proxy object, can I do modifications and still have
KVO notifications sent?
After reading the responses I am sure that this method is not adding the
data in the way that means KVO notifciations would be sent.
ADD METHOD
-(void)addData: (id) sender
{
NSString* newFirst = [firstNameField stringValue];
NSString* newLast = [lastNameField stringValue];
Data* newData = [[Data alloc]init];
[newData setValue:newFirst forKey:@"firstName"];
[newData setValue:newLast forKey:@"lastName"];
[arrayOfData addObject:newData];
if (table != nil)
NSLog(@"num is %d", [arrayOfData count]);
[table reloadData];
}
On Sat, Jun 21, 2008 at 4:40 AM, mmalc Crawford <email@hidden>
wrote:
>
> On Jun 20, 2008, at 10:16 PM, Alex Wait wrote:
>
> When the app starts, I see the data as expected. However, when I call my
>> add
>> function, which gets the strings from the textFields and makes the
>> new "Data" object and adds it to the array, I do not see it in the table.
>>
>> <http://homepage.mac.com/mmalc/CocoaExamples/controllers.html>
> Programmatic modifications to arrays not noticed by table view
>
> mmalc
>
>
--
If you can't be kind, at least have the decency to be vague.
_______________________________________________
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