drze7794 2013-06-16 12:16
浏览 35
已采纳

在iOS应用程序中使用来自Web服务的数据

I have to list the table entries from mysql in my iPhone app when a button is pressed. I am able to do it properly but it is just not the way I want it. I am using a PHP script to send Xcode what has to be printed.

First, I tried doing it using HTML table, but I didn't like the way it was printed with cells. Next I tried printing plain text by giving spaces(between columns) and for every new row. I used NSURL and loaded the webView to the iPhone. Looks good on browser but the same is not preserved when the iPhone tries to open it.

Is there a good way to do this? So I can just list the table entries without having to go through the traditional HTML table or any other idea is welcome.

Also, please try to be easily understood, as I am new to Obj-C, and PHP as well. Thanks!!

Any thoughts on how I can do this in a UITableView..?? Do I have to return a string with component separation characters and fill in the tableView?

  • 写回答

1条回答 默认 最新

  • doukou1718 2013-06-21 10:04
    关注

    Output the results encoded in JSON. Send an a(sync) request to the server using NSURLConnection or using a third-party library such as AFNetworking. Parse the JSON using NSJSONSerialization, turning the results into an array/dictionary depending on the contents. Then parse the results into the UITableViewCell. It may be easier to subclass the cell so that you include the data that you'd like to use.

    To encode the results from the database into JSON, you can use the method json_encode().

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 sql server2008r2索引超出了数组界限
  • ¥15 MATLAB图片转灰度格式问题
  • ¥15 把h5作品链接复制到自己的账号里
  • ¥15 ensp抓包实验配置
  • ¥15 强化学习算法、MRO
  • ¥15 想要学习一门技术来保证以后能够吃上碗饭,该学什么好
  • ¥50 Verilog硬件开发,射频分析求解答
  • ¥20 matlab绘冲床平面连杆机构图和仿真,求帮助
  • ¥15 为什么树莓派5b显示禁止连接
  • ¥15 请专家处理报错!基于深度学习的车型分类问题:数据集为包含 10 种车型的图像数据集,分为训练集、验证集和测试集。
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部