Re: Binding Tableviews (newbie) problems/questions
Re: Binding Tableviews (newbie) problems/questions
- Subject: Re: Binding Tableviews (newbie) problems/questions
- From: Scott Stevenson <email@hidden>
- Date: Mon, 3 Jan 2005 20:43:28 -0800
On Jan 3, 2005, at 5:08 PM, Vince Ackerman wrote:
I inadvertently posted this to mmalcom's list so forgive me
I've successfully used the tableview example at: http://cocoadevcentral.com/articles/000080.php to configure the bindings in mmalcolm's mailbox/email sample code
That's actually my sample code, but either way. :)
1. If I want to have the first column (of the email tableview) display the index number of the email array, is there a way to do this with binding's?
I can't think of an easy way to do this automatically in bindings. You'd probably have to do it manually in code. The code to do this in the way you describe is somewhat involved and would probably include concepts that aren't clear to you yet. In other words, there's no simple block I can think of to paste right in this message.
If I insert a new row in the tableview, I want the first column of every row to recalculate it's number to reflect the new order. He uses the "@count" operator to get the total number of objects in the array, but I want the cell to display it's row number.
The @count thing is an array operator, but you're actually looking to do something on individual items.
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."
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"];
Though I should emphasize that using a this method isn't the preferred way to go about things. There's probably an easier way to achieve what you're after
Hope this helps. Don't feel bad if this is confusing. Bindings is pretty advanced stuff!
- Scott
--
http://treehouseideas.com/
http://theocacao.com/ [blog]
_______________________________________________
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