ここに、配列を json に変換するこの PHP スクリプトがあります。
while($row = $result->fetch_row()){
$array[] = $row;
}
echo json_encode($array);
これを返す
[["No","2013-06-08","13:07:00","Toronto","Boston","2013-07-07 17:57:44"]]
今、この json コードの値をアプリのラベルに表示しようとしています。私の ViewController.m ファイルのコードは次のとおりです。
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSString *strURL = [NSString stringWithFormat:@"http://jamessuske.com/isthedomeopen/isthedomeopenGetData.php"];
// to execute php code
NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]];
// to receive the returend value
/*NSString *strResult = [[[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding]autorelease];*/
self.YesOrNow.text = [NSJSONSerialization JSONObjectWithData:dataURL options:0 error:nil];
}
しかし、私のラベルYesOrNowには何も表示されません:(何が間違っているのですか?
JSON ライブラリをインストールする必要がありますか?