如何从核心日期存储中提取特定属性

发布于 2024-11-27 15:34:18 字数 1242 浏览 0 评论 0原文

我正在执行带有排序描述符的获取请求来填充可变数组,如下所示:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

裸钻 2024-12-04 15:34:18

假设“年份照片”作为实体返回,您应该从 mutableFetchResultsA 中取出该对象,然后从该对象中查找 FriendsPhoto。我也不确定你的数据类型是什么,但我假设 FriendsPhoto 与 ImageArray 具有相同的类型。它会是这样的:

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

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];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文