首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过Xcode连接到mysql - appstore允许吗?

通过Xcode连接到mysql - appstore允许吗?
EN

Stack Overflow用户
提问于 2013-02-17 12:29:30
回答 1查看 331关注 0票数 0

我对obj-c非常陌生,我正在做这个应用程序,你可以点击一个注释,它会带你去这个国家。我想用一个外部php脚本连接到MySql:

代码语言:javascript
复制
<?php
include("connect.php");

$land = $_GET['land'];

$res = mysql_query("SELECT * FROM lande WHERE name = '$land'");
$row = mysql_fetch_array($res);

$flag = $row['flag'];

echo $flag;
echo $land;

?>

下面是我在Xcode中的按钮:

代码语言:javascript
复制
-(void)button:(id)sender {

 if (mapView.selectedAnnotations.count == 0)
 {
    //no annotation is currently selected
    return;
 }


 id<MKAnnotation> selectedAnn = [mapView.selectedAnnotations objectAtIndex:0];
 country_title = selectedAnn.title;


 UIViewController* Countries = [[UIViewController alloc] initWithNibName:@"Countries" bundle:[NSBundle mainBundle]];

 NSString *strUrl = [NSString stringWithFormat:@"http://localhost:8888/app/country.php?land=%@",country_title];

 NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:strUrl]];

 NSString *strResult = [[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding];

 NSLog(@"%@",strResult);


 [self.view addSubview:Countries.view];

}

如何打印我的结果?这是合法的吗?appstore会允许这样做吗?有没有别的办法呢?我知道SQLite,但它似乎很难…:(

EN

回答 1

Stack Overflow用户

发布于 2013-02-17 12:46:44

在您的应用程序中没有禁止使用外部数据库资源的规则。我一直使用这种方法来包含不能在本地存储的不断变化的额外数据。但是,您的设备上没有PHP服务器,因此要完全完成此操作,您需要连接到远程服务器。

如果你已经下定决心要在本地完成所有的工作,那么你可以在SQLite上多读一点,如果你能使用MySQL,那么使用SQLite就没问题了。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14917984

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档