开发者

Where store fetch array data?

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 * in开发者_StackOverflow中文版fo = [event values];
printf("\n%d", [event values]);
[mutableFetchResults release];  
[request release];  


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]);


if (!mutableFetchResults) { } 

any explanation for that ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜