Hi Daniel-

I just happened to be knocking out a prototype for something I'm working on 
with a similar structure to your example.  It consists of "steps" that can have 
many "ports", or step <->> port.  The example is pretty much code free; I was 
just trying to display and edit steps and ports using table views to manage 
both.  I use generic controllers in the .xib bound to the MOC, and UI elements 
bound to the proper controller.  I'd poke around and examine the model and xib 
files; you could even rename the pieces to match your situation.  You could add 
some more attributes to the ports (and more columns to the table) to model your 
transactions that you mentioned.

Download: http://www.positivespinmedia.com/dev/StepEdit.zip

Hope this helps... I know bindings can be one of those "picture worth a 
thousand words" things :-)

John

Positive Spin Media
http://www.positivespinmedia.com

On Dec 1, 2009, at 12:44 PM, Daniel Wambold wrote:

> Hello, List. I am a novice with CoreData and bindings and I've stumped myself 
> with this problem. I have created an xcdatamodel that contains 3 objects: an 
> Account object with a relationship property authorizedUsers, which is a 
> to-many relationship with a Person object. The Person object has a reciprocal 
> to-one relationship ("account") with the Account object. I have a table view 
> that shows all the accounts, and which, when I click on a given account, 
> should show, in a separate table view,  all the authorized users for that 
> account. The Person object has a read-only variable, nameAndID that 
> concatenates the first name, last name, and ID of the person entity. I feel 
> like I've tried every combination of bind to: and paths already. Right now, 
> I've only been successful by pushing a string into a scroll view with:
> 
> ----(from the Account.m file)----
> -(NSMutableString *)authorizedUsersNameID
> {
>       NSMutableString *myString = [[[NSMutableString alloc] init] 
> autorelease];
>       NSSet *mySetOfAuthorizedUsers = [self valueForKey:authorizedUsersKey];
>       int i=0;
>       for (Person *aPerson in mySetOfAuthorizedUsers)
>       {
>               ++i;
>               [myString appendFormat:@"%i: %...@\n",i, [aPerson 
> valueForKey:nameAndIDKey]];
>       }
>       return myString;
> }
> 
> ----And in the view controller object:----
> ...
>       NSEntityDescription *personEntityDescription = [NSEntityDescription 
> entityForName:PersonEntity inManagedObjectContext:moc];
>       NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
>       [request setEntity:personEntityDescription];
>       
>       // Set predicate and sort orderings...
>       NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == 
> %@)", mySelectedAccount];
>       [request setPredicate:predicate];
>       NSError *error;
>       NSArray *myAuthorizedUsers = [moc executeFetchRequest:request 
> error:&error];
>       if (myAuthorizedUsers == nil || [myAuthorizedUsers count] == 0)
>       {
>               // This is an error situation, as we should always have at 
> least the account owner as an authorized user.
>               NSLog (@"Search error: Authorized account users failed to match 
> any account.");
>       }
>       else
>       {
>               [myAccountUserTextView setString:@""];          // Clear out 
> the text view.
>               for (NSManagedObject *anAuthorizedUser in myAuthorizedUsers)
>               {
>                       [myAccountUserTextView insertText:[anAuthorizedUser 
> valueForKey:nameAndIDKey]];
>                       [myAccountUserTextView insertText:@"\n"];
>               }
>       }
> 
> The problem is that, I also want to bind Transaction objects (same 
> relationships as Person) but they have more information such as dates, 
> amounts, and so forth. I'd much rather do this with bindings than to create 
> strings if it can be done. If you know what sort of settings I need to 
> establish in IB to set this up (such as which bindings and what paths), 
> please take a moment to set me straight. The CoreData test model in IB 
> doesn't do this for me, so I can't crib those settings. I have working, 
> subclassed controllers for each managed entity type, and the data are clearly 
> appearing in the managed object (viz. the above code), so I suspect it's just 
> my binding settings that I've got wrong.
> Thanks for your insight!
> -Dan
> _______________________________________________
> 
> Cocoa-dev mailing list ([email protected])
> 
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/john%40positivespinmedia.com
> 
> This email sent to [email protected]

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to