Hello,
I have somewhat of a silly problem:
I am fetching a JSON array, which includes two-dimensional arrays;
And I am adding them to an NSMutableDictionary inside NSMutableArray:
Whereas "inst" is my multidimensional array, and it has an internal array which repeats itself (it's supposed to be a list of academic institutes, where each institute has ID, logo, name etc).
Problem is, after creating the table view, I am trying to populate the rows, and it fails:
I googled it for like 30 minutes and haven't found what I am doing wrong yet.
Your help would be greatly appreciated.
Thank you and have a great weekend,
Liroy
I have somewhat of a silly problem:
I am fetching a JSON array, which includes two-dimensional arrays;
And I am adding them to an NSMutableDictionary inside NSMutableArray:
Code:
for (NSDictionary *s in [json objectForKey:@"inst"])
{
NSMutableDictionary *arr=[[NSMutableDictionary alloc] init];
[arr setObject:[s objectForKey:@"i"] forKey:@"i"];
[arr setObject:[s objectForKey:@"user_id"] forKey:@"userID"];
[arr setObject:[s objectForKey:@"page_id"] forKey:@"pageID"];
[arr setObject:[s objectForKey:@"page_dep_code"] forKey:@"pageDepName"];
[arr setObject:[s objectForKey:@"link_url"] forKey:@"linkURL"];
[arr setObject:[s objectForKey:@"page_header_1"] forKey:@"pageHeader"];
[arr setObject:[s objectForKey:@"user_logo"] forKey:@"userLogo"];
[arr setObject:[s objectForKey:@"link_name"] forKey:@"linkName"];
[instNames addObject:arr];
}
Whereas "inst" is my multidimensional array, and it has an internal array which repeats itself (it's supposed to be a list of academic institutes, where each institute has ID, logo, name etc).
Problem is, after creating the table view, I am trying to populate the rows, and it fails:
Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
// this is the part where it fails
NSMutableDictionary *tl=[[NSMutableDictionary alloc] initWithDictionary:[instNames objectAtIndex:[indexPath row]]];
// end of failing part
NSString *str=[tl valueForKey:@"pageHeader"];
cell.textLabel.text=str;
return cell;
}
I googled it for like 30 minutes and haven't found what I am doing wrong yet.
Your help would be greatly appreciated.
Thank you and have a great weekend,
Liroy
Last edited: