textfield not updating with bindings - Whats wrong?
textfield not updating with bindings - Whats wrong?
- Subject: textfield not updating with bindings - Whats wrong?
- From: Kieren Eaton <email@hidden>
- Date: Sat, 23 Aug 2008 15:41:28 +0800
Hi all
I have given up on doing anymore work on my current project until i
get this sorted
ok simply i have an interface with 2 textfields, one for a number and
one for a string.
Also there is a button which tells the controller to tell my class to
update the model vars.
I am using Obj-C 2.0 and properties and from all i have read
properties are fully KVO complient.
here is my app delegate.
#import <Cocoa/Cocoa.h>
@class someclass;
@interface bindingstestDelegate : NSObject{
someclass *fooClass;
}
- (IBAction)changeValues:(id)sender;
@end
----------------------------------------
#import "someclass.h"
@implementation bindingstestDelegate
- (id) init{
self = [super init];
if (self != nil) {
fooClass = [[someclass alloc] init];
}
return self;
}
- (IBAction)changeValues:(id)sender{
[fooClass updateValues];
}
@end
and the model class
@interface someclass : NSObject {
NSString *someString;
NSInteger someNumber;
}
@property (readwrite,retain) NSString *someString;
@property (readwrite) NSInteger someNumber;
- (void)updateValues;
@end
---------------------------------
#import "someclass.h"
@implementation someclass
@synthesize someString, someNumber;
- (id) init{
self = [super init];
if (self != nil) {
self.someString = @" fred rocks";
self.someNumber = 6969;
}
return self;
}
- (void)updateValues
{
self.someString = [someString stringByAppendingString:@" YEP"];
self.someNumber = self.someNumber + 5;
NSLog(@"\n%d - %@",someNumber,someString);
}
@end
Right so in IB I have an object which is of class "someClass" and an
object controller which has the content outlet set to the "someclass"
object and the keys "someString","someNumber".
The button calls the changeValues method in the delegate
The 2 textfields are bound to the controller with selection.someString
and selection.someNumber respectively.
upon application start the text fields are set with their respective
values as per the init of the model. which shows that the bindings are
working.
BUT pressing the button yields no change from the textfields. The
nslog shows the model values are changing but this is not propogated
to the UI.
Whats going on?
According to the Apple docs on troubleshooting bindings "The model
class has automatic key-value observing enabled or implements manual
key-value observing for the property." its obviously not manual so huh?
Help and clarification or discussion much appreciated.
Kieren
Olearia - Talking Books on the Mac
http://olearia.googlecode.com/
_______________________________________________
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