FROM : Davide Scheriani
DATE : Fri Feb 01 19:44:03 2008
hello!
ive got a Window Panel with a nice NSTableView.
I called the class "MyClass" where delegate and dataSource.
Ive got 2 colums where I have assigned the identifer as "param" and
"paramValue".
Till here nothing to worry. I just implemented the delegates and the
chance to edit the cells.
Ive got even two NSMutableArray and a NSDictionary.
-(id)init{
[super init];
params = [[NSMutableArray alloc] init];
paramsValue = [[NSMutableArray alloc] init];
extraDictArray = [[NSMutableDictionary alloc] initWithCapacity:2];
[extraDictArray setObject:params forKey:@"param"];
[extraDictArray setObject:paramsValue forKey:@"paramValue"];
return self;
}
- (int)numberOfRowsInTableView:(NSTableView *)tableView {
return [params count];
}
- (id)tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn
row:(int)row {
NSParameterAssert(row >= 0 && row < [params count]);
NSArray *theValue = [extraDictArray objectForKey:[tableColumn
identifier]];
return [theValue objectAtIndex:row];
}
- (void)tableView:(NSTableView *)aTableView
setObjectValue:(id)anObject
forTableColumn:(NSTableColumn *)tableColumn
row:(int)row {
NSString *value = [[extraParamsTable selectedCell] stringValue];
NSArray *theArray = [extraDictArray objectForKey:[tableColumn
identifier]];
[theArray replaceObjectAtIndex:row withObject:value];
}
and just for the record ive got an NSTextView where I print out the
param and the paramValue
so I know that it works.All the datas into the two array are added
with no problem and everything works fine.
Now Ive got another class "MySecondClass", where I do want access this
two NSMutableArray,
so I do this:
- (IBAction) updateParams:(id) sender{
int row = [masterList selectedRow];
NSLog(@">> %@",[[masterObj objectAtIndex:row] valueForKey:@"params"]);
}
what Ive got here is always an empty array..why?
call a metod (selector) inside the Panel (so the "MyClass") works, but
from another class it doesnt works.
If I call another object like an NSString *test =@"hello!": like
NSLog(@">> %@",[[masterObj objectAtIndex:row] valueForKey:@"test"]);
it works..:( have no clue at all why.
and If I add some object inside the arrays outside the delegate method
(ex in the init method)
-(id)init{
[super init];
params = [[NSMutableArray alloc] init];
[params addObject:@"goofy1"];
[params addObject:@"goofy2"];
return self;
}
I get the array with the objects inside.It works.
any solutions?
tnx guys.
DATE : Fri Feb 01 19:44:03 2008
hello!
ive got a Window Panel with a nice NSTableView.
I called the class "MyClass" where delegate and dataSource.
Ive got 2 colums where I have assigned the identifer as "param" and
"paramValue".
Till here nothing to worry. I just implemented the delegates and the
chance to edit the cells.
Ive got even two NSMutableArray and a NSDictionary.
-(id)init{
[super init];
params = [[NSMutableArray alloc] init];
paramsValue = [[NSMutableArray alloc] init];
extraDictArray = [[NSMutableDictionary alloc] initWithCapacity:2];
[extraDictArray setObject:params forKey:@"param"];
[extraDictArray setObject:paramsValue forKey:@"paramValue"];
return self;
}
- (int)numberOfRowsInTableView:(NSTableView *)tableView {
return [params count];
}
- (id)tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn
row:(int)row {
NSParameterAssert(row >= 0 && row < [params count]);
NSArray *theValue = [extraDictArray objectForKey:[tableColumn
identifier]];
return [theValue objectAtIndex:row];
}
- (void)tableView:(NSTableView *)aTableView
setObjectValue:(id)anObject
forTableColumn:(NSTableColumn *)tableColumn
row:(int)row {
NSString *value = [[extraParamsTable selectedCell] stringValue];
NSArray *theArray = [extraDictArray objectForKey:[tableColumn
identifier]];
[theArray replaceObjectAtIndex:row withObject:value];
}
and just for the record ive got an NSTextView where I print out the
param and the paramValue
so I know that it works.All the datas into the two array are added
with no problem and everything works fine.
Now Ive got another class "MySecondClass", where I do want access this
two NSMutableArray,
so I do this:
- (IBAction) updateParams:(id) sender{
int row = [masterList selectedRow];
NSLog(@">> %@",[[masterObj objectAtIndex:row] valueForKey:@"params"]);
}
what Ive got here is always an empty array..why?
call a metod (selector) inside the Panel (so the "MyClass") works, but
from another class it doesnt works.
If I call another object like an NSString *test =@"hello!": like
NSLog(@">> %@",[[masterObj objectAtIndex:row] valueForKey:@"test"]);
it works..:( have no clue at all why.
and If I add some object inside the arrays outside the delegate method
(ex in the init method)
-(id)init{
[super init];
params = [[NSMutableArray alloc] init];
[params addObject:@"goofy1"];
[params addObject:@"goofy2"];
return self;
}
I get the array with the objects inside.It works.
any solutions?
tnx guys.
| Related mails | Author | Date |
|---|---|---|
| No related mails found. | ||






Cocoa mail archive

