I'm new to Objective-C coding. However, my problem is very straightforward if you take a look at the image below of my output. Basically I want everything to be aligned correctly such that all the data in the rows look like they are in their own columns. Basically each row should be aligned with the row above it. My program is bringing in each field from a JSON file from the web - please also see code to see how I'm doing it.
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSDictionary *allDataDictionary = [NSJSONSerialization JSONObjectWithData:webData options:0 error:nil];
for (NSDictionary *diction in allDataDictionary) {
NSString *currDate = [diction objectForKey:@"Current Date"];
NSString *timePeriod = [diction objectForKey:@"Time Period"];
NSString *transCount = [diction objectForKey:@"Transaction Processed"];
NSString *approved = [diction objectForKey:@"Approved"];
NSString *posApproved = [diction objectForKey:@"Standing App"];
NSString *approvalRate = [diction objectForKey:@"Approval Rate"];
NSString *respTime = [diction objectForKey:@"Resp Time"];
[array addObject:[NSString stringWithFormat:@"%@ %@ %@ %@ %@ %@", timePeriod, transCount, approved, posApproved, approvalRate, respTime]];
} [[self myTableView] reloadData];
My Table View:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(!cell)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// NSString *currDate = [[array objectAtIndex:indexPath.row] objectForKey:@"Current Date"]; //added
// NSString *someOtherKey = [[array objectAtIndex:indexPath.row] objectForKey:@"Some other key"]; //added
cell.textLabel.text = [array objectAtIndex:indexPath.row];
// cell.textLabel.text = [NSString stringWithFormat:@"%@ %@", currDate, someOtherKey]; //added
return cell;
}