• 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: NS(Array)Controller and To-Many Relationships (how to add objectsfrom one to another)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NS(Array)Controller and To-Many Relationships (how to add objectsfrom one to another)


  • Subject: Re: NS(Array)Controller and To-Many Relationships (how to add objectsfrom one to another)
  • From: アンドレ(Andre) <email@hidden>
  • Date: Sat, 5 Feb 2005 14:13:36 -0800

Right, I don't actually need two separate NSArrayControllers, I suppose my problem is,

I'm trying to 1)bind a table column to the value (name) of the columns, but only ones that

are contained in the selected document in the parent. and 2) add a column only to the current selected

document (the to-many relation) so that when I change the selected document in one table view,

only that selected one's columns are shown in the second table view (selection.columns.columnName)

but I can't get the binding to work because of errors:


I actually disposed of the second Array Controller and added an addColumn: method to
the first controller:

#import "SheetController.h"


@implementation SheetController

- (IBAction)addColumn:(id)sender
{
id object = [self valueForKeyPath:@"selection.columns"];
NSLog(@"object is %@",object);
[object add:sender];
//NSLog(@"Sent to super from subclass");
}


@end

when I invoke this method I get this NSLog result "object is <NO SELECTION MARKER>"
and an error: [_NSStateMarker add:]: selector not recognized [self = 0x306210]....

So what I'm guessing is that the to-many is empty, and the columns keypath is wrong??

BTW, Thanks for you help.

On 平成 17/02/05, at 13:19, Christiaan Hofman wrote:


If I understand you correctly, you have an array of model objects (managed by NSArrayController1), and each model object has (its own) array of objects (managed by NSArrayController2).

First of all: do you want to have a separate NSArrayController2 for each of the arrays in the model objects? Or do you want to manage one array at a time (the selected one)?

In any case, I would say that you use the 'add' method of NSArrayController2 to add an object to the array. If you link the contents of NSArrayController2 to the 'column' of the selection of NSArrayController1, this should work OK. Certainly if your model objects implement the KVC methods to access an array, this should be noticed properly.

On Feb 5, 2005, at 22:42, アンドレ(Andre) wrote:

Hi, just getting started with bindings (read almost all of the apple docs)
and have a fairly good idea how bindings work (KVO/KVC/KVB) and
read up on NSController and NSArrayController etc. but I am having a problem
to associate the objects in one NSArrayController to another.

Here is my object graph: NSArrayController containing the model object that has a few to-one
properties, and one that contains a to-many relationship (NSArray)
and another NSArrayController that contains another model that I want
to insert into the array in the first...

Put into easier terms, I have a table object (NSArrayController1) that has some properties,
and then I have some column objects (NSArrayController2), now when I add/insert objects
into Controller 2, I actually want it to go into NSArrayController1.columns (or the current selection).
I am trying to override the add method on the second arraycontroller to send it to table.columns (the NSArray)
but I wonder how to do this... with KVB? (objectForKey:selection.column)? and then manually insert
it? Doesn't this short circuit validation because the NSArrayController wouldn't manage one of the NSArray
it is holding?

Just wondering how other people handle to-many relationships and piping the add actions of one
group of objects (displayed in a table view) to add to the selected object(s) in another array?

Thanks for any help!


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >NS(Array)Controller and To-Many Relationships (how to add objects from one to another) (From: アンドレ(Andre) <email@hidden>)

  • Prev by Date: Re: checking if an object's instance exists.
  • Next by Date: importing tab-delimited table (newbie)
  • Previous by thread: NS(Array)Controller and To-Many Relationships (how to add objects from one to another)
  • Next by thread: Re: NS(Array)Controller and To-Many Relationships (how to add objectsfrom one to another)
  • Index(es):
    • Date
    • Thread