I am on OS X 10.6, XCode 3.2.2, GC and Core Data. I have a single entity app where I subclassed NSManagedObject so I can generate a "Job Ticket ID" for my Job entity whenever a new Job is inserted. However I am getting an error in my Log that is complaining that...
-[NSCFNumber count]: unrecognized selector sent to instance 0x20001ab40 The property I am trying to get the max value for is defined as a 16 Integer. The code is below and was taken from "Fetching Specific Values" @ http://developer.apple.com/mac/library/documentation/cocoa/conceptual/CoreData/Articles/cdFetching.html#//apple_ref/doc/uid/TP40002484-SW1 -(void)awakeFromInsert { NSFetchRequest *theRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *theEntity = [NSEntityDescription entityForName:@"TKJob" inManagedObjectContext:[self managedObjectContext]]; [theRequest setEntity:theEntity]; [theRequest setResultType:NSDictionaryResultType]; // Create an expression for the key path. NSExpression *theKeyPathExpression = [NSExpression expressionForKeyPath:@"myID"]; NSExpression *theMaxExpression = [NSExpression expressionForFunction:@"max:" arguments:[NSArray arrayWithObject:theKeyPathExpression]]; // Create an expression description using the theMaxExpression and returning a Number. NSExpressionDescription *theExpressionDescription = [[NSExpressionDescription alloc] init]; [theExpressionDescription setName:@"maxID"]; [theExpressionDescription setExpression:theMaxExpression]; [theExpressionDescription setExpressionResultType:NSInteger16AttributeType]; [theRequest setPropertiesToFetch:[NSArray arrayWithObject:theExpressionDescription]]; // Execute the fetch. NSError *theError; NSArray *theResultsArray = [[self managedObjectContext] executeFetchRequest:theRequest error:&theError]; if (theResultsArray == nil) { // Handle the error. } else { if ([theResultsArray count] > 0) { // do some math and set myID to maxID + 1 } } } Any thoughts?_______________________________________________ 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 arch...@mail-archive.com