开发者

Quick Question About Fetch And NSObject

开发者 https://www.devze.com 2023-03-14 10:58 出处:网络
I have the following code that fetches a Session object for a particular Exercise object. This fetch loads data into my UITableView.

I have the following code that fetches a Session object for a particular Exercise object.

This fetch loads data into my UITableView.

The count is开发者_高级运维 fine, I just need a way to extract the Session.timeStamp property so I can set it to UITableViewCell's textLabel property.

Does anyone know how?

NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"name == %@", exercise.name]];
NSEntityDescription *sessionEntity = [NSEntityDescription entityForName:@"Exercise" inManagedObjectContext:managedObjectContext];
[fetchRequest setEntity:sessionEntity];

NSError *error = nil;
NSArray *results = [managedObjectContext executeFetchRequest:fetchRequest error:&error];
NSMutableArray *mutableSessionArray = [NSMutableArray array];
for (Exercise *ex in results) {
    Session *session = [ex exercises];
    [mutableSessionArray addObject:session];
    }
self.sessionArray = [NSArray arrayWithArray:mutableSessionArray];


Call timestamp property of your mananged object subclass or call valueForKey.

0

精彩评论

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