Note that there are some explanatory texts on larger screens.

plurals
  1. POApp with UITableView runs on iPad simulator but crashes on the iPhone simulator
    primarykey
    data
    text
    <p>I have implemented an universal app that can run on all iOS devices. Recently, I encountered a weird problem which my app will go fail on the iPhone simulator, but will go smooth on the iPad simulator.</p> <p>I have found out which part in my program had bugs, but I had no idea to fix it. In the AppDelegate, I have this code:</p> <pre><code>id someController=[self.tabBarController.viewControllers objectAtIndex:3]; if ([someController isKindOfClass:[UINavigationController class]]){ someController = [someController topViewController]; } if ([someController isKindOfClass:[iPhone_ASRAViewController class]]) { iPhone_ASRAViewController *myIPhone_ASRAViewController=(iPhone_ASRAViewController*)someController; myIPhone_ASRAViewController.listData=[NSArray arrayWithArray:vocabulary_]; [myIPhone_ASRAViewController.table reloadData]; } </code></pre> <p>The app load data,called vocabulary_ from remote database fulfilled by JSON into my iPhone_ASRAViewContriller's NSArray property, called listData, and then show it on the tableview.</p> <p>In order to concatenate vocabulary showed in the table, I have code as following:</p> <pre><code>NSMutableArray *cells = [[NSMutableArray alloc] init]; for (NSInteger j = 0; j &lt; [table numberOfSections]; ++j) { for (NSInteger i = 0; i &lt; [table numberOfRowsInSection:j]; ++i) { [cells addObject:[table cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:j]]]; } } NSString *postmsg=@"SA_VC=0&amp;select_language=english&amp;txtFilePath="; for (UITableViewCell *cell in cells) { NSString *temp=[postmsg stringByAppendingString:cell.textLabel.text]; postmsg=[temp stringByAppendingString:@"\r\n"]; } NSString *final_postmsg=[postmsg stringByAppendingString:@"&amp;waveBase64=%@"]; NSLog(@"%@",final_postmsg); </code></pre> <p>When I simulate the app on the iphone simulator, there are some error message:</p> <pre><code> *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil' </code></pre> <p>The app seems not to concatenate the string in "table" under the iPhone simulator. Can anyone provide me with a suggestion? </p> <p>The following code are my implementation of tableView:cellForRowAtIndexPath:</p> <pre><code>static NSString *TableIdentifier = @"tableidentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:TableIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:TableIdentifier] autorelease]; NSDictionary *voc_list=[listData objectAtIndex:indexPath.row]; NSLog(@"%@",voc_list); cell.textLabel.text = [[(NSDictionary*)voc_list objectForKey:@"vocabulary_list"]objectForKey:@"Vocabulary"]; cell.detailTextLabel.text=[[(NSDictionary*)voc_list objectForKey:@"vocabulary_list"]objectForKey:@"Translation"]; cell.textLabel.font = [UIFont boldSystemFontOfSize:15]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload