0
我一直試圖解析一個數組並將其分割爲單獨的字符串。在設置字符串時,我成功地通過單獨添加固定的objectAtIndex
來成功完成這項工作。從表視圖解析數組到單個字符串 - Objective-C
例子:
NSString *weightString = [[[results valueForKey:@"Endurance"] objectAtIndex:7]objectAtIndex:2];
然而,當我嘗試和使用任何objectAtIndex
字符串始終返回null在的tableView didSelectRowAtIndexPath
設置字符串。我需要能夠使用objectAtIndex:indexPath.row
點擊tableView行。我無法弄清楚我出錯的地方。隨意請求更多的代碼或查詢。
查詢:
PFQuery *arrayQuery = [PFQuery queryWithClassName:@"Exercises"];
[arrayQuery selectKeys:@[@"Endurance"]];
[arrayQuery orderByAscending:@"ExerciseName"];
[arrayQuery findObjectsInBackgroundWithBlock:^(NSArray *results, NSError *error) {
if (!error) { self.arrayResults = [results valueForKey:@"Endurance"];
的cellForRowAtIndexPath:
- (TableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"list";
TableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
UILabel *cellTitle;
cell.cellTitle.text = [[browseAllArray objectAtIndex: indexPath.row] objectForKey:@"ExerciseName"];
if (cell == nil) {
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell = [[TableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
//Exercise Bar Label
cellTitle = [[UILabel alloc] initWithFrame:CGRectMake(80, 20, 220, 60)];
cellTitle.font = [UIFont fontWithName:@"ethnocentric" size:14];
cellTitle.textColor = [UIColor blackColor];
cellTitle.numberOfLines = 2;
cellTitle.textAlignment = NSTextAlignmentCenter;
cell.cellTitle.text = [[browseAllArray objectAtIndex: indexPath.row] objectForKey:@"ExerciseName"];
[self.tableView reloadData];
}
cellTitle.text = [[browseAllArray objectAtIndex:indexPath.row]objectForKey:@"ExerciseName"];
return cell;
share cellForRowAtIndex方法。 –
顯示'result'和'tableView:cellForRowAtIndexPath:' – Larme
我的cellForRowAtIndexPath方法只包含設計單元的代碼。我試圖解析信息從我的數據庫相應的相關細胞。你還需要它嗎?如果是的話,我會發送它。 – HJDavies