Re: NSArrayController
Re: NSArrayController
- Subject: Re: NSArrayController
- From: Camillo Lugaresi <email@hidden>
- Date: Tue, 27 Dec 2005 17:41:41 +0100
On 08/dic/05, at 01:50, David Piasecki wrote:
Following an example, I used an NSArrayController and set bindings
to an NSTableView. The code below results in the desired output;
however, I received errors at runtime. I had a similar problem with
NSTreeController, but I'd like to get the NSArrayController working
first. The example code produces no errors.
2005-12-07 16:10:46.252 Raptor[13018] *** -[_NSControllerArrayProxy
firstIndex]: selector not recognized [self = 0x6fa1a0]
2005-12-07 16:10:46.376 Raptor[13018] *** -[_NSControllerArrayProxy
firstIndex]: selector not recognized [self = 0x6fa1a0]
Maybe you bound the wrong key in the nib?
- (void)LoadEventLog
{
LogMessageArray = [[NSMutableArray alloc] initWithCapacity:100];
for( int i = 0; i < 100; i++ )
{
NSMutableDictionary *LogDictionary = [[NSMutableDictionary alloc]
init];
[LogDictionary setObject:@"Testing" forKey:@"EventText"];
[LogDictionary setObject:[NSString localizedStringWithFormat:@"%
d", i] forKey:@"EventID"];
[LogDictionary setObject:@"My Date/Time" forKey:@"DateTime"];
[LogMessageArray addObject:LogDictionary];
}
[LogArrayController setContent:LogMessageArray];
}
LogArrayController looks like a class. You should stick to the Cocoa
convention of making variable and method names lowercase and
reserving uppercase for class names.
The example code...
- (void) awakeFromNib
{
int theLoop;
theListing = [[NSMutableArray alloc] initWithCapacity:27];
for ( theLoop = 0; theLoop < 27; theLoop++ ) {
NSMutableDictionary* theEntry;
NSString* firstStr;
NSString* secondStr;
theEntry = [[NSMutableDictionary alloc] init];
firstStr = [NSString stringWithFormat:@"Row %d", theLoop+1];
[theEntry setObject:firstStr forKey:@"colOne"];
secondStr = [NSString stringWithFormat:@"Hidden pref #%d", theLoop
+1];
[theEntry setObject:secondStr forKey:@"colTwo"];
[theListing addObject:theEntry];
}
[myController setContent:theListing];
}
That leaks 27 NSMutableDictionary instances.
Camillo
_______________________________________________
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