After more research, I found my solution in the NSPersistentDocument
Tutorial. If anyone else has this problem, I needed to implement the
following method in the subclass for my entity:

+ (NSSet *)keyPathsForValuesAffectingProperty3{
        return [NSSet setWithObjects:@"property1", @"property2", nil];
}

Also, declare the property in the entity's subclass header like this:

@property (nonatomic, readonly) NSString * property3;




On Tue, Sep 29, 2009 at 1:32 PM, John McIntosh
<johntmcint...@googlemail.com> wrote:
> 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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to