XCode, Tabellenansicht cellForRowAtIndexPath

Ich weiß, dass es eine einfache Lösung dafür gibt, aber ich kann scheinbar nicht sagen: /

cell.textLabel.text = [BooksBorrowed objectAtIndex:0];

In meiner cellForRowAtIndexPath-Methode ist bookName eine Zeichenfolge. Es stürzt ab und hinterlässt keinen Fehler im Protokoll. Ich weiß nicht, was ich falsch mache.

bookName ist ein String, den ich von JSON Parsing bekomme und der Inhalt hat.

(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath   *)indexPath
 {
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault   reuseIdentifier:CellIdentifier] autorelease];
    }

    NSLog(@"Book Name is %@", BooksBorrowed[0]);
    cell.textLabel.text = [BooksBorrowed objectAtIndex:0];

    return cell;
  }

So erhalte ich das Array BooksBorrowed:

 - (void)updateMyBooks
  {
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        // Fetch data on a background thread:
        NSString *authFormatString =
        @"http://localhost:8888/Jineel_lib/bookBorrowed.php?uid=%d";

        NSString *urlString = [NSString stringWithFormat:authFormatString, 1];

        NSURL *url = [NSURL URLWithString:urlString];

        NSString *contents = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];

        response1 = [contents JSONValue];

        if (contents) {
          NSMutableArray *newBooksBorrowed = [NSMutableArray array];

          // ... Parse JSON response and add objects to newBooksBorrowed ...
          BookName = [[NSString alloc]init];
          DateBorrowed = [[NSString alloc]init];
          BookID = [[NSString alloc]init];
          BookExtended = [[NSString alloc]init];
          BookReturned = [[NSString alloc]init];

          BookName = [response1 valueForKey:@"BookName"];
          BookID = [response1 valueForKey:@"BookID"];
          DateBorrowed = [response1 valueForKey:@"DateBorrowed"];
          BookExtended = [response1 valueForKey:@"Extended"];
          BookReturned = [response1 valueForKey:@"Returned"];
          NSLog(@"Book Name is %@", BookName);

          [newBooksBorrowed addObject:BookName];

          dispatch_sync(dispatch_get_main_queue(), ^{
          // Update data source array and reload table view.
          BooksBorrowed = newBooksBorrowed;
          [self.tableView reloadData];
        });
    }
});

}

Antworten auf die Frage(3)

Ihre Antwort auf die Frage