Core Data Calculated Properties
Core Data Calculated Properties
- Subject: Core Data Calculated Properties
- From: John McIntosh <email@hidden>
- Date: Tue, 29 Sep 2009 13:32:48 -0500
Hi all. I am working on a core data application and am having some
difficulty understanding how to configure a particular aspect of it.
I am using an nstable to display a selection of properties from my
core data managed object. I have the properties bound to the columns
in the table and set to Continuously Updates Value. For most
properties this works as expected.
For example, I have a button that loads a value into property1. When
pressed, the value is automatically updated in the table. I have
another button that loads a different value into property2. Again,
this is automatically updated. Lastly, the value of property3 should
be the result of a function based on properties1 and 2. I have
declared property3 as a transient value and have subclassed my entity.
In the .m file for my subclass I have the following function:
-(NSString *)property3{
NSString *p1 = [self valueForKey:@"property1"];
NSString *p2 = [self valueForKey:@"property2"];
NSMutableString *result = "";
[result stringByAppendingString[p1]];
[result stringByAppendingString[p2]];
return result;
}
In the GUI, when I press the buttons, the columns for property1 and
property2 update immediately. However, the column with property3 only
updates when something else changes in the table. For example,
clicking a row or making another entry.
Is this the correct setup for having a calculated value? If so, is
there a way I can force the table to retrieve the new calculated value
any time another property changes?
_______________________________________________
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