我想创建一个包含 MySQL 表行内容的 NSArray
我用一个php脚本来获取数据
$response = $bdd->query('SELECT * FROM iPhoneTests');
while ($datas = $response->fetch())
{
?>
<array>
<integer><?php echo $datas['Temperature']; ?></integer>
</array>
<?php
}
并测试我在我的应用程序中使用此代码
NSURL *getTemperature = [NSURL URLWithString:@"myURL..."];
NSError* error;
temperature = [NSArray arrayWithContentsOfURL:getTemperature ];
NSLog(@"%@",temperature);
当我在我的网络浏览器中测试时,我获得了所有数据,但在我的应用程序中,使用 NSlog 我只获得了第一个值。
我已经解决了这个问题好几次了,但是我不能成功 如果有人看到我的错误请告诉我
最佳答案
您正在为每一行创建一个数组(顺便说一句,这是无效的,因为这些数组也必须嵌套到一个数组中)。
这样做:
$response = $bdd->query('SELECT * FROM iPhoneTests');
?><array><?
while ($datas = $response->fetch())
{
?>
<integer><?php echo $datas['Temperature']; ?></integer>
<?
}
?></array>
关于php - 使用行内容创建 NSArray (MySQL),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4312874/