Re: textfield not updating with bindings - Whats wrong?
Re: textfield not updating with bindings - Whats wrong?
- Subject: Re: textfield not updating with bindings - Whats wrong?
- From: Markus Spoettl <email@hidden>
- Date: Sat, 23 Aug 2008 10:05:34 -0700
On Aug 23, 2008, at 5:16 AM, Kieren Eaton wrote:
ok the delegate is set as an object in IB it is the delegate of
Files owner and nsapplication (thats correct isnt it?) it has a
class of bindtestdelegate which is where the button action is located.
The button calls the changeValues method in the delegate class which
then calls the updateValues in the fooClass instance
of the someclass.
should my filesOwner in IB (Currently it is NSApplication) be
something different?
Well, that depends, in most cases it's good to have a
NSWindowController or NSViewController as file owner since those take
care of memory management of the nib file. But I believe it's
irrelevant to the problem at hand.
the instance of someClass is just dragged straight out of the IB lib
as a simple object and assigned the class "someClass"
I dont actually have a "nsobjectcontroller subclass" .h/.m in my
project but according to the apple docs I dont need one?
No, you don't, you just mentioned you used one.
As far as I can tell from your explanation, you have 1
bindingstestDelegate object (the file's owner) and one extra someClass
object. The problem is that your delegate class creates its own
someClass instance and when you press the button that instance get
changed, not the other instance you created in the nib file.
I would change the code so that the bindingstestDelegate class exposes
a readonly property named fooClass. You then remove the extra
someClass object from your nib and bind the NSTextFields to the file's
owner "fooClass.someString" and "fooClass.someNumber" keys.
I would also suggest you change the naming slightly, using uppercase
first characters for class names. This makes it easier to distinguish
classes from instances, methods and properties. More details here:
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_950_section_12.html#/
/apple_ref/doc/uid/TP30001163-CH3-TPXREF108
Markus
--
__________________________________________
Markus Spoettl
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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