• 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
Re: Bindings Driving Me CRAZY. :'(
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bindings Driving Me CRAZY. :'(


  • Subject: Re: Bindings Driving Me CRAZY. :'(
  • From: Gustavo Pizano <email@hidden>
  • Date: Tue, 13 Oct 2009 20:07:41 +0200

SuccesS!!!! :D:D:D

Ok I have success, but I stepped away from what you told me,,, in a way.
What I did was:
In the AwakeFromNib method of the parent Controller, (the one that holds the UserListController and the InvoiceEditionController).


-(void)awakeFromNib{
if(_userListController == nil){
_userListController = [[UserListViewController alloc] initWithNibName:@"UserListView" bundle:nil];
}
[_myUserListView addSubview:[_userListController view]];
[NSBundle loadNibNamed:@"InvoiceEditionView" owner:_userListController];
[_myContentView addSubview:[[_userListController _invoiceEdViewController] view]];
}


So I instantiated _userListController normally, passing the Nib file that will control. then well add the view and then I load the .xib "InvoiceEditionView" and set the owner to _userListController. Now before going to the next line in this code:

In UserListView .xib, I added the NSArrayController that has the data.
In InvoiceEditionView.xib, I set the class of the File's owners to UserListViewController, then I place an NSObject and called Controller, and the class of this Controller is InvoiceEditionViewController.
In UserListViewController I declared a IBOutlet and connected to the Controller I have just placed in InvoiceEditionView.xib. then I connected from Controller the outlet view eventually to the view that is in the xib.


Then in the view I placed the label and bind the value to File's owner (Which is USerListViewController) and the Model Key Path to _userListArrayController.selection.completeName.

and IT WORKED!! I will try placing a NSObjectController and setting the label's value to it and see what happens. :D:D:


Thanks for the help

Gustavo






On Oct 13, 2009, at 1:41 AM, Keary Suska wrote:

On Oct 12, 2009, at 1:33 PM, Gustavo Pizano wrote:

Keary Hello:


This doesn't appear sensible, and you may have a number of problems. First, make sure that InvoiceEditionViewController is being instantiated
this is what Im doing: in the awakeFromNib

if(_userListController == nil){
_userListController = [[UserListViewController alloc] initWithNibName:@"UserListView" bundle:nil];
}
if(_invoiceController == nil){
_invoiceController = [[InvoiceEditionViewController alloc] initWithNibName:@"InvoiceEditionView" bundle:nil];
}
[_myUserListView addSubview:[_userListController view]];
[_myContentView addSubview:[_invoiceController view]];
[_invoiceController setUserController:_userListController];

You mentioned having an outlet from the UserListViewController to the InvoiceEditionViewController--this can only be accomplished in the InvoiceEditionViewController is in the UserListViewController's nib, in which case you are instantiating two different InvoiceEditionViewControllers and hence experiencing problems.


If the InvoiceEditionViewController is *not* in the UserListViewController nib, the above should work fine, except still consider the NSObjectController but with the correct key path.

properly. Second, simply have a reference to UserListViewController in InvoiceEditionViewController, which can be an outlet if

ok done I have now there this : IBOutlet UserListViewController * userController;

This is only useful if the InvoiceEditionViewController is instantiated in the UserListViewController nib, If it is, then chances are that the InvoiceEditionViewController is not being instantiated correctly unless you have overridden -init or - initWithCoder:, depending on the super class.


InvoiceEditionViewController can be sensibly instantiated via xib, or set by other means. I recommend then to have an NSObjectController in InvoiceEditionViewController.xib whose content is bound to UserListViewController.NSArrayController.selection (using correct ivar/property names, of course).
Ok I tried but when wan tto bind the labels to show the details I bind it to the NSObjectControlled I just configured, and the controller key goes to selection, which its not good, so whe I run I see its NO Selection. label.

No, "selection" is the correct controller key for data access. It is confusing for an object controller as there will only be one selection (or none), but that is how it works.


I did instead was to place an NSArrayController (users) in IB and bind the contents to userController._userListArrayController.arrangedObjects.
then the labels I bind the values to users, and the controller key to selection and the path to the attributes of the entity.

And it works 50%, I can see the values., but when I select another user, the values dosn't change, it's seems its getting only the 1st value of the array.

Of course. You are creating a whole different array controller that has its own selection semantics. Bindings are automatic but not magic. Scrap the array controller approach. It won't work. Do an NSObjectController instead.


Google "binding across nibs" (you may need to try a few variations on the preposition for best results) and you will find numerous discussion and techniques.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


_______________________________________________

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


References: 
 >Bindings Driving Me CRAZY. :'( (From: Gustavo Pizano <email@hidden>)
 >Re: Bindings Driving Me CRAZY. :'( (From: Keary Suska <email@hidden>)
 >Re: Bindings Driving Me CRAZY. :'( (From: Gustavo Pizano <email@hidden>)
 >Re: Bindings Driving Me CRAZY. :'( (From: Keary Suska <email@hidden>)

  • Prev by Date: viewWillDisappear not being called
  • Next by Date: [MEET] Chicago CocoaHeads / CAWUG Tuesday October 13th
  • Previous by thread: Re: Bindings Driving Me CRAZY. :'(
  • Next by thread: More Core Data Questions
  • Index(es):
    • Date
    • Thread