Re: programmatically updating an MO's attribute/field
Re: programmatically updating an MO's attribute/field
- Subject: Re: programmatically updating an MO's attribute/field
- From: "Frederick C. Lee" <email@hidden>
- Date: Mon, 30 Jan 2006 11:39:11 -0800
Most of my data is bound.
The main viewing area is like a person's plate with the salad bar
containing bound MOs
(via their respective NSArrayControllers). The user should be able
to choose a
particular image/info via NSPanels (sheets).
The user should be able to choose a set of images with their
respective NSAttributeStrings
(arranged via their respective NSArrayControllers) and display in a
common area.
The NSTextView in the 'common area' (main panel) should be editable
and stored
back to the previously-chosen MO.
Here's what I've been toying with (checking the MO out, and replacing
it):
EntityManagedObject *theObject = [[gvRegionMapController
selectedObjects] objectAtIndex:0];
NSAttributedString *myString = [[NSAttributedString alloc]
initWithString:@"Hello World!"];
[theObject setValue:myString forKey:@"memo"]; // transient field.
[gvRegionMapController removeObject:[[gvRegionMapController
selectedObjects] objectAtIndex:0]];
[gvRegionMapController addObject:theObject];
[theObject release];
--------------------------------------------
I got an error on this one:
*** -[NSConcreteAttributedString addLayoutManager:]: selector not
recognized [self = 0x374410]
I what to be able to have the NSArrayController aware of this so the
user can see the change in real time.
Do I need to send a notification?
For the moment I have a make-shift button that does this as a proof-
of-concept.
Does this appear a good approach to you?
Ric.
On Jan 30, 2006, at 10:38 AM, Matt Neuburg wrote:
Accepting that for some reason you don't want to use bindings up
front (at
least I assume you don't, since you say this NSTextView is
unbound), why not
just do it the old-fashioned way? Simply call the MO's
setValue:forKey: as
necessary. You will presumably want some way of knowing when it is
time to
do this, so you'll probably want to set up a delegate for the text
view (or
in some other way get a signal from the interface). m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide
<http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>
_______________________________________________
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