[SOLVED] Re: NSTextField setStringValue not updating properly
[SOLVED] Re: NSTextField setStringValue not updating properly
- Subject: [SOLVED] Re: NSTextField setStringValue not updating properly
- From: email@hidden
- Date: Thu, 11 Dec 2008 13:28:29 -0500
I am posting this for the benefit of those who are coming into this
area as new folk. Thanks to anyone who provided help. This is a
short description of how I solved my issue and not meant to be a
tutorial of any kind.
After staring at it for multitudes of hours, I decided a different
approach was necessary.
What I ended up doing was implementing KVC and KVO for the variable
with which I was experiencing trouble. This is (at least) done by
creating a property, or by implementing the getter(s)/setter(s) w/ the
appropriate key-value observing structure.
There are probably a number of examples out there. Hillegass
demonstrates that in his book (I keep touting it - it's good).
I bound the textfield's value to the member of the class that was
used. That addressed the issue of keeping the textfield up-to-date
with the value of the variable as required.
I did, however, run into another issue: the run loop.
Coming from the VB world, I hadn't really needed any sort of variables
(extremely rarely, if ever) that "hung around." Most everything I did
there stuck by nature of the beast (depending upon where it was
declared).
Here, however, one has to deal with "the run loop." I may not have a
complete understanding of it, however, the part that matters for this
thread is that given a set of code it will only execute that code once
and only on the information it has at the time of execution. Thus, if
you need to pass data from one execution loop to another (think
callback), it needs to persist. That's done either through the
keyword static or, in the case of an NSObject of some kind, retain.
In summary, changing over to KVC w/ KVO plus the retention factor
fixed my issues. So, if you are having trouble with setStringValue,
make sure you are going the KVC w/ KVO route & check your bindings.
Peace, Love, and Light,
/s/ Jon C. Munson II
_______________________________________________
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