Tôi là một nhà phát triển Android có kinh nghiệm đang cố gắng tải mẫu ứng dụng iOS chạy bằng dịch vụ Parse và sdk (https://www.parse.com/).Không thể truy xuất updatedAt hoặc tạo các giá trị At từ các đối tượng Parse
Thật tuyệt vời và tôi có thể nhận tất cả các đối tượng và giá trị của chúng mà không gặp khó khăn, mọi thứ đều hoạt động tốt.
Tuy nhiên, tôi không thể nhận giá trị được cập nhật tự động do Parse tạo cho từng đối tượng.
Đó là điều bắt buộc đối với tôi và tôi không muốn lưu dấu thời gian có điều kiện dưới dạng Chuỗi khi dữ liệu đang ngồi ngay tại đó.
Đây là ý chính của những gì tôi đang làm.
- (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;
}
Bạn thấy gì trong cửa sổ trình gỡ lỗi nếu bạn làm NSLog (@ "date% @", được cập nhật); sau NSDate * updated = [object objectForKey: @ "updatedAt"]; – Yan
bạn đã thử [object stringForKey: @ "updateAt"] chưa? –