• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Bindings confusion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bindings confusion


  • Subject: Bindings confusion
  • From: Simon Raisin <email@hidden>
  • Date: Tue, 28 Apr 2009 06:04:55 -0700

Hi,
I'm running into a binding issue is my main application so I wrote a small
test app to try to track down the problem: primarily that I cannot get the
UI to update appropriately when it is configured to observe my model objects
via bindings.


// AppDelegate.h
@class ModelObject;
@interface AppDelegate : NSObject {
    ModelObject *modelObject;
    int _someProperty;
}

@property int someProperty;

- (IBAction)doSomething:(id)sender;

@end

// AppDelegate.m
@implementation AppDelegate
@synthesize someProperty = _someProperty;

- (void)awakeFromNib
{
    modelObject = [[ModelObject alloc] init];
}

- (void)dealloc
{
    [modelObject release];

    [super dealloc];
}

- (void)doSomething:(id)sender
{
    [modelObject changeValue];
}

// ModelObject.h
@interface ModelObject : NSObject {
    int _someProperty;
}

@property int someProperty;

- (void)changeValue;

@end

// ModelObject.m
@implementation ModelObject

@synthesize someProperty = _someProperty;

- (id)init
{
    if (nil == (self = [super init]))
        return nil;

    self.someProperty = 10;

    return self;
}

- (void)changeValue
{
    self.someProperty = (_someProperty == 10) ? 5 : 10;
}

@end

In my xib I I have an object that represents my AppDelegate.  I bind the
value of an NSLabel to the AppDelegate's modelObject.someProperty keypatch.

But no matter what I do the value is never updated in the UI.  Do you see
something obvious that I am missing?

This is a retain/release Cocoa app running on 10.5.6 using Xcode 3.1.2.

Any guidance would be appreciated,
CxT
_______________________________________________

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

  • Follow-Ups:
    • Re: Bindings confusion
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: Getting Display Names
  • Next by Date: Group Identity Programming
  • Previous by thread: Re: Cookie accept policy
  • Next by thread: Re: Bindings confusion
  • Index(es):
    • Date
    • Thread