On Nov 7, 2008, at 8:37 AM, Benjamin Dobson wrote:
Hi all,I'm trying to use an NSTableView for the first time. I've got a four- column table view set up in IB, and class files for the dataSource as follows:// snipped .m: @implementation FetchHighscores - (IBAction)fetchResults:(id)sender {finalData = [NSMutableArray arrayWithCapacity:4]; // To prevent it being (null) NSString *string = @"1,1,1 2,2,2 3,3,3 4,5,6 7,3,4" // etc. Loaded from an external source.NSArray *components = [results componentsSeparatedByString:@"\n"];NSArray *template = [NSArray arrayWithObjects:@"Col1", @"Col2", @"Col3", @"Col4", nil];int loops = [components count]; int loop; for (loop = 0; loop < loops; loop++) { currentData = [NSMutableArray arrayWithCapacity:4]; [currentData addObject:@"0"];[currentData addObjectsFromArray:[[scores objectAtIndex:loop] componentsSeparatedByString:@","]]; while ([currentData count] < 4) // External source isn't entirely consistent. This is just a placeholder.{ [currentData addObject:@"0"]; }NSDictionary *dict = [NSDictionary dictionaryWithObjects:currentData forKeys:template];[finalScores insertObject:dict atIndex:loop]; } [theTable reloadData]; } // snipped I'm getting strange errors. In the console, I get:*** -[NSRectSet objectAtIndex:]: unrecognized selector sent to instance 0x1516c220But sometimes I get a different error: the NSParameterAssert isn't satisfied.What needs changing? Thanks.
Greetings, Benjamin,This one looks fairly easy to solve to me; when you get random errors involving classes that you're not using, it's often a memory problem. In this case, you are not retaining finalData in the -fetchResults: -- so finalData is in fact *still* null, as you're initializing it with a method that returns an autoreleased array. Try this instead:
finalData = [[NSMutableArray alloc] initWithCapacity:4]; // To prevent it being (null)
Be sure to release it somewhere, typically -dealloc.Also, if you're using Garbage Collection, this may not hold -- but I suspect from the situation that you aren't.
Cheers, Andrew
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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]