我有一个UISplitView
,我试图用数据库中的值填充左侧控制器。 我有这个phpcode。从页面获取数据到程序
$query = "SELECT name FROM country";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result)){
$json_output[] = $row;
}
echo json_encode($json_output);
但是,当我进入我的ios应用程序。我有这样的代码在我viewDidLoad
NSURL *myURL = [NSURL URLWithString:@"http://www.mywebsite.com/index.php"];
NSArray *test= [[NSArray alloc] initWithContentsOfURL:myURL];
TypesArray=[[NSMutableArray alloc]initWithContentsOfURL:test];
和cellforRowAtIndexpat
我加
cell.textLabel.text=[TypesArray objectAtIndex:indexPath.row];
因此,当我跑我的节目,我希望看到在leftviewcontroller
列出了我的价值观,但遗憾的是它显示了空白。NSLog
也显示为空,想要一些帮助,为什么我的价值观没有被拉到我的应用程序。
感谢
你能NSURL * myURL ...后插入下面的代码:NSError *错误= nil; NSString * str = [NSString stringWithContentsOfURL:myURL] encoding:NSUTF8StringEncoding error:&error]; NSLog(@“%@”,str); ? – stosha
你知道如何解析json或xml吗?请学习它,并在Google中为它做一些RND。 –
@NitinGohel嗯,我实际上已经在另一个应用程序中使用过这个json,我正在做它的工作。我的问题在于我的程序没有收到链接中的任何内容吗? –