开发者

How to extract specific attribute from core date store

I'm executing a fetch request with sort descriptor to populate a mutable array as follows:

NSFetchRequest *requestA = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"YearPhoto" inManagedObjectContext:managedObjectContext];
[requestA setEntity:entity];

NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
[requestA setSortDesc开发者_如何学Goriptors:sortDescriptors];
[sortDescriptor release];
[sortDescriptors release];

NSError *error = nil;
NSMutableArray *mutableFetchResultsA = [[managedObjectContext executeFetchRequest:requestA error:&error] mutableCopy];
if (mutableFetchResultsA == nil) {

}
[self setImageArray:mutableFetchResultsA];
[mutableFetchResultsA release];
[requestA release];

I need to extract the attribute of YearPhoto, friendsPhoto (UIImage ~60KB stored in core data store) to setImageArray for use here in an animation within a UIImageView.....

 self.theImageView.animationImages = [NSMutableArray initWithArray:imageArray];

I have also tried:

self.theImageView.animationImages = [NSArray initWithObjects:yearPhoto.friendsPhoto, nil];

I can't work it out. Checked docs but they are not very clear on this specific problem

Anyone see the error in my ways?


Assuming that "Year Photo" is being returned as an Entity you should take the object out of the mutableFetchResultsA and then lookup the friendsPhoto from that object. I'm also not sure what you datatypes are but I'm assuming friendsPhoto is of same type as ImageArray. It would be something like this:

YearPhoto* photo = [mutableFetchResultsA objectAtIndex:0];
[self setImageArray:photo.friendsPhoto];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜