Re: NSTableView and Bindings
Re: NSTableView and Bindings
- Subject: Re: NSTableView and Bindings
- From: David Gardener <email@hidden>
- Date: Fri, 25 Mar 2005 15:21:05 -0700
Steve, thanks for the reply. I tried to explain this as best I can. Hope you can understand. If not I can send you an XCode example.
This would be the code:
Columns "Interface";
@interface column: NSObject
{
(double)column1;
(double)column2;
(double(column3;
(double)column4;
(double)column5'
(double)column6;
}
-(void)setColumn1:(double)x;
-(void)setColumn2:(double)x;
-(double)Column3;
-(double)column4;
-(void)setcolumn5(double)x;
-(double)column6;
@end
Columns "Implementation"
(id)init
{
[super init];
//defaultValues for typed in columns
[self setColumn1:0.00];
[self setColumn2:0.00];
[self setColumn5:0.00];
//This next init is for the sum of columns 1&2 into table column3.
[Column setKeys;
[NSA
rray arrayWithObjects:
nil]
triggerChangeNotificationsForDependentKey:
@"column3"];
//Column 4,5 &6 are textfield values.
//Column4 is the value of "@sum.column3 and is set in the bindings window
Bind to: NSArraycontroller
Controller Key: arranged Objects
Model Key path: @sum.column3
//This is where I'm having problems; using the value "@sum.column3" in textfield Column4
// is a read only number. How do I get this into a usable number for the next calculation.
//
The value for this Init goes into a textField. Not sure if I can use @sum.column3 as an object in the array??
[Column setKeys;
[NSA
rray arrayWithObjects:
nil]
triggerChangeNotificationsForDependentKey:
@"column6"];
-(double)column1
{
return (double)column1;
}
-(void)setColumn1:(double)x
{
column1 = x;
}
-(double)column2
{
return (double)column2;
}
-(void)setColumn2:(double)x
{
column1 = x;
}
(double)column3
{
return (double)(column1) +(column2);
}
// Everything is ok up to here except that the Value for Column3 can't be used in another calculation. (would have to use-(double)columnx{return(double)((columny)+(column1 + column2));
// I think because it a read only value in the tableView??? I didn't think I needed a setter as it is set in the [Column setKeys[NSArray init method] - right???
// If I do need a setter method what would it be???
//Column4 is a textField which takes the calculated value for @sum.column3 set in the bindings window for that TextField as outlined above. Do I need a setter/getter method for this, and if I do what would it be???
-(double)column5
{
return (double)column5;
}
-(void)setColumn5:(double)x
{
column1 = x;
}
-(double)column6
{
return (double)(column4)+(column5);
//Can't get this to work ??? Column 4 is the Textfield with the value "@sum,column3" set by the bindings window and is read only.
//Columns1,2 &5 are statically typed in values. columns3,4 &6 are programmed values.
}
@end
If this isn't clear enough I'll send you a XCode example. Again thanks for the time and energy - much appreciated!!!!!!
On Mar 24, 2005, at 6:22 AM, Steven Kramer wrote:
Op 23-mrt-05 om 20:25 heeft David Gardener het volgende geschreven:
My apology for misleading, the additional @ was spurious. Should read [Columns setKeys:[NSArray arrayWithObjects: @"column1,@"column2", nil]
triggerChangeNotificationForDependentKey: @"column3"];
This init method sets the array for changes in column1 and column2's values and responds with a result for column3. -right?
method is: -(double)column3{ return (double)(column1 + column2);}
This works as it should. When I go to use the value of column3 or @sum.column3, in the next calculation eg:
[Columns setkeys; [[NSArray arrayWithObjects:@"column1",@"column3"(or @"@sum.column3"-not actual code),nil]
triggerChangeNotificationForDependentKey: @"column4"];
with method: -(double)column4{ return (double)(column1 + column3);}
It won't work, I think because the value of Column 3, or if I use @sum,column3, is a read only value. All these are number values.
Could you post some actual code? For instance, in this sample, you treat 'column3' as an instance variable, not a method like below. Is that actual code?
-(double)column4{ return column1 + [self column3]; }
I'm also using another window to add,delete, & insert rows and add the value information into the tableView though KVC, KVO and Bindings. This window does some other calculations of values that are entered into the TableView. The table won't update the calculated values until I add or delete a row. Question is: how do I get the calculated values into a usable format and also get the table to reload the values without having to add or delete a row from the second window??? Thanks again!!!
Try [yourArrayController rearrangeObjects] and be sure to read the documentation on that method.
Regards,
Steven Kramer
--
email@hidden
http://sprintteam.com/
_______________________________________________
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