配列の内容を uitableview に表示しようとしています。値を個別に割り当てると正常に動作しますが、配列からそれらを表示しようとすると、xcode は (lldb) 以外のデバッグ レポートに何も表示されずに終了します。テーブルビューのあるページに移動するまで、コンパイルしてうまく動作します。エラーを調べたところ、メモリ割り当てに関連しているようですが、一部の JSON クラスが動作するために ARC を有効にする必要があるため、手動で何も解放できません。誰でも見て、問題の可能性があるものを確認できますか。
- (void)viewDidLoad
{
[super viewDidLoad];
theArray = [[NSArray alloc] initWithObjects:@"1","2","3","4",nil];
// Do any additional setup after loading the view.
}
#pragma mark Table view methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [theArray count];
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Set up the cell...
self.recentSearchesTable.backgroundColor =[UIColor clearColor];
self.recentSearchesTable.separatorColor = [UIColor clearColor];
cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:15];
cell.textLabel.text = [theArray objectAtIndex:indexPath.row];
cell.contentView.backgroundColor = [UIColor clearColor];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// open a alert with an OK and cancel button
NSString *alertString = [NSString stringWithFormat:@"Clicked on row #%d", [indexPath row]];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:alertString message:@"" delegate:self cancelButtonTitle:@"Done" otherButtonTitles:nil];
[alert show];
}