【发布时间】:2015-12-08 14:14:30
【问题描述】:
我是一位经验丰富的 Android 开发人员,正在尝试使用 Parse 服务和 sdk (https://www.parse.com/) 运行原型 iOS 应用程序。
太好了,我可以毫不费力地获得所有对象及其值,一切正常。
但是,我无法获取 Parse 为每个对象自动创建的 updatedAt 值。
这对我来说是必须的,当数据就在那里时,我不想将额外的时间戳保存为字符串。
这是我正在做的事情的要点。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
// this works fine
cell.textLabel.text = [object objectForKey:@"name"];
//substring however does not
NSDate *updated = [object objectForKey:@"updatedAt"];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"EEE, MMM d, h:mm a"];
cell.detailTextLabel.text = [NSString stringWithFormat:@"Lasted Updated: %@", [dateFormat stringFromDate:update]];
//i also tried like this at first
cell.detailTextLabel.text = [NSString stringWithFormat:@"Lasted Updated: %@", [object objectForKey:@"updatedAt"]];
return cell;
}
【问题讨论】:
-
如果你执行 NSLog(@"date %@",updated); 你会在调试器窗口中看到什么NSDate *updated = [object objectForKey:@"updatedAt"];
-
你试过 [object stringForKey:@"updateAt"] 吗?
标签: ios objective-c parse-platform