【发布时间】:2015-02-09 17:12:02
【问题描述】:
我正在使用Parse 创建此表视图,并试图弄清楚如何将Parse 表数据放入数组中,因此我可以将其传递给WatchKit InterfaceController 以显示完全相同东西?
所以我想在 WatchKit 界面中准确显示 iPhone 界面中显示的内容。
这是我所拥有的,如果我可以添加任何有用的内容,请告诉我:
TableVC.m:
- (id)initWithCoder:(NSCoder *)aCoder
{
self = [super initWithCoder:aCoder];
if (self) {
self.parseClassName = @"na";
self.textKey = @"dateTime";
self.pullToRefreshEnabled = YES;
self.paginationEnabled = NO;
}
return self;
}
- (PFQuery *)queryForTable
{
PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];
return query;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object
{
static NSString *simpleTableIdentifier = @"RecipeCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
UILabel *homeLabel = (UILabel*) [cell viewWithTag:101];
homeLabel.text = [object objectForKey:@"test"];
UILabel *dateLabel = (UILabel*) [cell viewWithTag:102];
dateLabel.text = [object objectForKey:@"dateTime"];
return cell;
}
Parse data:
TableVC.m:
我已经设置了基本的 WatchKit 文件和 Storyboard。我硬编码了一个数组来测试它是否正常工作。但是现在我只需要从Parse 获取数据到那里,并且不确定我是否需要进行查询然后将其变成公共array?
编辑:
这是我的查询:
PFQuery *query2 = [PFQuery queryWithClassName:@"nba"];
[query2 findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
// The find succeeded.
NSLog(@"Objects 2: %@", objects);
}
} else {
// Log details of the failure
NSLog(@"Error 2: %@ %@", error, [error userInfo]);
}
}];
这是我的 NSLog:
NSLog(@"Objects 2: %@", objects);
控制台:
2015-02-09 21:06:30.845 SimpleTable[8373:1284663] Objects 2: (
"<na: 0x7ff3f8e40880, objectId: cOrjeAmwJh, localId: (null)> {\n away = Cav;\n date = \"04/19/2015\";\n dateTime = \"April 19, 2015, 16:00\";\n gNumber = 1;\n home = Bul;\n matup = \"Ca\";\n ro = \"Ro \";\n test = \"Test 2\";\n tv = T;\n}",
【问题讨论】:
标签: ios arrays uitableview parse-platform watchkit