mysqlサーバーにデータを保存するテーブルベースのアプリがあります。アプリは更新され、永続化のためにデータをnsdictionaryに書き込みます。データに変更を加えるときは、テーブルを更新する必要があります。ただし、[self tableview reloadData]を配置すると、行を選択するとアプリがクラッシュします。テーブルを更新する方法について誰かがアイデアを持っていますか?これを捨てて、データからオブジェクトを作成して使用する必要がありますか?
ありがとう。
-(void) loadData3;{
MyAppDelegate *AppDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
self.tableDataSource3 = [AppDelegate.data3 objectForKey:@"Rows"];
NSLog(@"AppDelegate.data3 : %@",AppDelegate.data3 );
NSLog(@"self.tableDataSource3 : %@",self.tableDataSource3 );
}
- (void)viewDidLoad {
[super viewDidLoad];
[self loadData3];
if(CurrentLevel3 == 0) {
self.navigationItem.title = @"Family";
}
else
self.navigationItem.title = CurrentTitle3;
}
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}
これがcellForRowAtIndexPathメソッドです。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
// Set up the cell...
NSDictionary *dictionary = [self.tableDataSource3 objectAtIndex:indexPath.row];
cell.textLabel.text = [dictionary objectForKey:@"Title"];
return cell;
}