开发者

Quick Question About Fetch And NSObject

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜