如何从核心日期存储中提取特定属性
我正在执行带有排序描述符的获取请求来填充可变数组,如下所示:
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 setSortDescriptors: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];
我需要将 YearPhoto、friendsPhoto(UIImage ~60KB 存储在核心数据存储中)的属性提取到 setImageArray,以便在 UIImageView 内的动画中使用。 ....
self.theImageView.animationImages = [NSMutableArray initWithArray:imageArray];
我也尝试过:
self.theImageView.animationImages = [NSArray initWithObjects:yearPhoto.friendsPhoto, nil];
我无法解决。检查了文档,但他们对这个具体问题不是很清楚
有人看到我的方式中的错误吗?
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 setSortDescriptors: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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设“年份照片”作为实体返回,您应该从 mutableFetchResultsA 中取出该对象,然后从该对象中查找 FriendsPhoto。我也不确定你的数据类型是什么,但我假设 FriendsPhoto 与 ImageArray 具有相同的类型。它会是这样的:
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: