I am tying to display in my table view an array that is on a database on parse.com I can display the first item in the array, but not the rest.
- (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];
}
_ListArray = [object objectForKey:@"content"];
NSLog(@"OBJECT = %@",_ListArray);
NSString *cellValue = [NSString stringWithFormat:@"%@", [_ListArray objectAtIndex:indexPath.row]];
cell.textLabel.text = cellValue;
if(refresh <counter)
{
NSString *br = @"<br>";
List = [NSString stringWithFormat:@"%@%@%@", List, br, cell.textLabel.text];
NSLog(@"%@",List);
refresh ++;
}
cell.accessoryType =UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
If I try to use:
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [_ListArray count];
}
I get nothing in the table.
edit update:
did remove the self.ListArray and going with _ListArray.
in the h file:
NSMutableArray *ListArray;
...
@property (retain, atomic) NSMutableArray *ListArray;
and then in m file:
@synthesize ListArray = _ListArray;
regarding the:
self.ListArray = [object objectForKey:@"content"];
the object is the PFObject.
i have queryForTable where i get the data from parse.
- (PFQuery *)queryForTable {
PFQuery *query = [PFQuery queryWithClassName:@"List"];
[query whereKey:@"user" equalTo:[PFUser currentUser]]; // user
[query whereKey:@"objectId" equalTo:[theListID objectId]]; // the specific list
counter =[query countObjects];
NSLog(@"%d",counter);
// If Pull To Refresh is enabled, query against the network by default.
if (self.pullToRefreshEnabled) {
query.cachePolicy = kPFCachePolicyNetworkOnly;
}
// If no objects are loaded in memory, we look to the cache first to fill the table
// and then subsequently do a query against the network.
if ([self.objects count] == 0) {
query.cachePolicy = kPFCachePolicyCacheThenNetwork;
}
[query orderByDescending:@"createdAt"];
return query;
}
And to the objectForKey:@"content"]; content is the name of the column in my class on parse so i need to say what object from the class i want to get, and that is the array column named "content"
The logg, (when the NSLog is active on the array.
Inköpslista[7856:12e03] Warning: A long-running Parse operation is being executed on the main thread.
Break on warnParseOperationOnMainThread() to debug.
2013-10-21 14:23:31.008 Inköpslista[7856:12e03] 1
2013-10-21 14:23:31.017 Inköpslista[7856:12e03] OBJECT = (
"Br\U00f6d",
Anka,
Boll,
Sko
)
2013-10-21 14:23:31.017 Inköpslista[7856:12e03] <html><body><br>Bröd
2013-10-21 14:23:31.545 Inköpslista[7856:12e03] OBJECT = (
"Br\U00f6d",
Anka,
Boll,
Sko
)
self.ListArray = [object objectForKey:@"content"];? If you're using the parse provided table view controller you just need to configure the cell for the passed object...