データベースからデータを読み取り、テーブルビューにロードするアプリを xcode 4.2 で開発しましphpMyAdmin
た。で同じことをすると、xcode 4.3
もう機能しません。何日も前から解決策を探していますが、何も見つからず、なぜ機能しないのかわかりません (私のデータベースと php スクリプトは正常に機能します)。
FirstViewController.h:
NSMutableArray *myArray;
FirstViewController.m:
- (void)viewDidLoad {
[super viewDidLoad];
NSURL *url = [NSURL URLWithString:kGETUrl];
NSData *data = [NSData dataWithContentsOfURL:url];
NSError *error;
myArray = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions
error:&error];
[self.tableView reloadData];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [myArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
NSDictionary *info = [myArray objectAtIndex:indexPath.row];
cell.textLabel.text = [info objectForKey:@"name"];
cell.detailTextLabel.text = [info objectForKey:@"Message"];
return cell;
}