JSON から Web データを更新する際に大きな問題があります。SO 私は、JSON URL からの解析を使用した単純な TableView を持っています。ボタンを押すと、JSON からの情報が tableviewCell に書き込まれますが、この情報はいつでも更新される必要があります。SO私は私のコードを持っています:
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
NSURL *url = [NSURL URLWithString:@"http://url.json"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
connection = [NSURLConnection connectionWithRequest:request delegate:self];
if (connection) {
webdata = [[NSMutableData alloc]init];
[mytableview reloadData];
}
このコードを書きましたが、情報が更新されません。何が間違っていますか? ViewDidAppear、viewWillAppearも試しました。しかし、何もありません。
cellForRow メソッドを追加しました。
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(! cell)
{
cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]autorelease];
}
cell.textLabel.text = [array objectAtIndex:indexPath.row];