views:

28

answers:

2

I try [eventArray value] but nothing - i get like that 78999 3451237 3451237

But must be 90

NSEntityDescription *entity = [NSEntityDescription entityForName:@"Event" inManagedObjectContext:app.managedObjectContext];   
NSFetchRequest *request = [[NSFetchRequest alloc] init];  
[request setEntity:entity];   
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"values" ascending:NO];  
NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];  
[request setSortDescriptors:sortDescriptors];  
[sortDescriptor release];   
NSMutableArray *mutableFetchResults = [[app.managedObjectContext executeFetchRequest:request error:&error] mutableCopy];   
if (!mutableFetchResults) { }    
[self setEventArray: mutableFetchResults];  
event = [eventArray objectAtIndex:3];
NSNumber * info = [event values];
printf("\n%d", [event values]);
[mutableFetchResults release];  
[request release];  
A: 
if (!mutableFetchResults) { } 

any explanation for that ?

TheSquad
if (!mutableFetchResults) { // Handle the error. // This is a serious error and should advise the user to restart the application }
Andrew E
Right, but right here you do not check if there is an error... your false result may come from that ? try a NSLog to check it out
TheSquad
A: 

I am assuming that the event variable here:

event = [eventArray objectAtIndex:3];

is an NSManagedObject whose entity has a numerical attribute named values. If so, then [event values] will return an NSNumber instance and not an int or double. Therefore, this line:

printf("\n%d", [event values]);

... will not print out the double value of the returned NSNumber instance but instead a decimal representation of the instances address in memory. To log the actual value you need to use:

printf("\n%d", [[event values] intValue]);
TechZen