• 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
How do I get indirect binding to work?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How do I get indirect binding to work?


  • Subject: How do I get indirect binding to work?
  • From: Bob Ueland <email@hidden>
  • Date: Fri, 5 Oct 2007 10:28:58 -0700 (PDT)

In “Cocoa Bindings Programming Topics “ from ADC, on page 18 there is a Figure 6 called “Typical bindings configuration using existing controller”. (In figure 6 there is MyDocument between  NSObjectController and the model object). A quote from the text

“Although the NSController instance is conceptually bound directly to its model object, in most situations the binding will be “indirect,” to a variable in your document object, as shown in Figure 6.”


I’m trying to figure out how to get this “indirect binding” to work.

First I created a simple app consisting of a single text field which I bound to a model called title. The model title is a instance variable belonging to a class called Book. Here’s how my Book class looks like:

@interface Book : NSObject
{
    NSString *title;
}
-(NSString *) title;
-(void)setTitle:(NSString *) title;
@end


In the IB I have essentially 4 objects
1. a text field (NSTextField)
2. NSObjectController
3. an instance of a Book.
4. File’s Owner (which I don’t use yet)

Here are the connections and choices I made in IB.

NSObjectController Inspector
    Connections
        Outlets/content:Book
    Attributes
        Mode: Class
        Object Class Name: NSMutableDictionary
        Keys:title

NSTextField Inspector
    Bindings
        Bind to: NSObjectController
        Controller Key: selection
        Model Key Path: title

This app works. But my question is how to modify this app so that I introduce MyDocument between the NSObjectController and the Book instance?

I suspect that
1. NSObjectController content should point at MyDocument
2. MyDocument should have an outlet (which I called book), pointing at my Book object.
3. NSTextField Inspector Model Key Path: should be changed from title to book.title

Is this correct? I tried this but my app keeps crashing on quit from app.

Bob





____________________________________________________________________________________
Pinpoint customers who are looking for what you sell.
http://searchmarketing.yahoo.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

  • Follow-Ups:
    • Re: How do I get indirect binding to work?
      • From: Keary Suska <email@hidden>
  • Prev by Date: Re: NSTableView questions
  • Next by Date: Re: MVC roles of objects in pattern
  • Previous by thread: Re: NSTableView questions
  • Next by thread: Re: How do I get indirect binding to work?
  • Index(es):
    • Date
    • Thread