Re: Binding Tableviews (newbie) problems/questions
Re: Binding Tableviews (newbie) problems/questions
- Subject: Re: Binding Tableviews (newbie) problems/questions
- From: Vince Ackerman <email@hidden>
- Date: Wed, 05 Jan 2005 07:18:13 -0800
On Jan 3, 2005, at 20:43, Scott Stevenson wrote:
That's actually my sample code, but either way. :)
OOPS.... sorry! I've been studying it and it's helped me a lot, thanks!
2. I want to get values for each key/value pair in the email array from somewhere else in my project and use them in the "add" and "insert" methods
I'm not sure what you mean by "somewhere else in my project."
I guess I meant I have another part of the UI where the individual "emails" are entered... I'm actually not creating anything like your mailbox / email example but the tableviews are the same so I am staying with your example to make it easier to talk about it. I did add a method to the email object to add the current index in the array to the first column and that works now.
Creating a new mailbox, then creating a new email for that mailbox, does call the addEmail method but it doesn't show up in the email tableview.... until I create a second mailbox, select that, and then select first mailbox. Then the emails in the first mailbox will show up. I'm not savvy enough to know what I'm missing here.
The UI action methods don't send KVO (key-value observing) notifications, so the table view doesn't know anything has changed. A quick and dirty solution would be to change -addEmail to do this (untested):
[self willChangeValueForKey:@"emails"];
[emails addObject: newEmail];
[self didChangeValueForKey:@"emails"]
Could you explain this? I don't understand who is getting the notification for this. I added this to the addEmail method in the controller object and it does allow the values in each email object to show up in the email tableview, but the original problem remains: When I first create the mailbox object, then create a new email, it doesn't show up in the email tableview. It only will appear after I created a second mailbox, then re-select the first mailbox. This holds true for any mailbox I create. It's individual emails won't show up until I select any other mailbox then re-select that mailbox. Just to test this, I have an "insert" button for the email tableview and it's connected to the insert method (like your example) in the email arrayController and that works normally... the new email shows up in the tableview when created.
Bindings are not intuitive at all!! I would love to understand them but there doesn't seem to be much info available that's written for bone heads like me. I don't understand all the options such as arrangedObjects, selectedObjects, selection, selectionIndex, selectionIndexes, etc. Someone could write an entire "Bindings for dummies" book on this one subject and make a killing.... Are you interested?
Thanks for all you help on this!
Vince Ackerman
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden