iPhone开发可以参考以下:
http://www.cocoachina.com/iphonedev/index.html
http://www.apple.com.cn/developer/iphone/
iPhone的应用程序,开发者上传到appstore,分为收费跟免费两种。
iPhone的所有者可以从appstore下载程序使用。呵呵,不少收费application的开发者都成了百万富翁哦。
下面要讨论的是:C/S模式的应用程序。
iPhone的application应用程序日趋强大,以至于大多数的程序都不局限于独立运行在iPhone上,它们需要联机,需要从server获取数据,需要利用server存储信息。
我在项目中的做法:
iPhone app端利用Get或者POST向server发送请求。
小量数据用Get,表格之类用Post。用户信息相关https,server相应加上非https勿入。
关键在于server!从request请求中取得参数,处理完毕,怎么样返回给iPhone app。
XML! 对。
server把返回值依照相约格式生产XML。
iPhone app通过解析XML得到返回值。
e.g.
<dict>
<key>Name</key>
<string>John Doe</string>
<key>Phones</key>
<array>
<string>408-974-0000</string>
<string>503-333-5555</string>
</array>
</dict>
dict表示范围
key表示变量名
第一个变量Name, String型的,值为John Doe
第二个变量Phones,String型的数组
code:
使用dom4j
Document document = DocumentHelper.createDocument();
Element dictElement = document.addElement("dict");
Element arrayElement = dictElement.addElement("array");
List<BusinessVO> businessList = otherService.getBuildingBusinessList(buildingId, Integer.parseInt(verifyStatus));
for(BusinessVO business : businessList){
Element businessElement = arrayElement.addElement("business");
Element retElement = businessElement.addElement("key");
retElement.setText("businessId");
Element retValue = businessElement.addElement("String");
retValue.setText(business.getId());
Element retElement1 = businessElement.addElement("key");
retElement1.setText("businessName");
Element retValue1 = businessElement.addElement("String");
retValue1.setText(business.getBuildingName());
………………
省略n行
结果为:
<dict>
−
<array>
−
<business>
<key>businessId</key>
<String>100022796</String>
<key>businessName</key>
<String>1 Leroy St</String>
<key>businessContent</key>
<String/>
<key>phoneNumber</key>
<String>(646) 666-4835</String>
<key>address</key>
<String>1 Leroy St</String>
<key>website</key>
<String/>
<key>category</key>
<int>0</int>
<key>refBusinessId</key>
<String>0</String>
<key>agreeCount</key>
<int>0</int>
<key>disagreeCount</key>
<int>0</int>
<key>relocatedListCount</key>
<int>0</int>
<key>notedListCount</key>
<int>0</int>
<key>userId</key>
<String>0</String>
<key>centerX</key>
<int>49822</int>
<key>centerY</key>
<int>23253</int>
</business>
−
<business>
<key>businessId</key>
<String>100022797</String>
<key>businessName</key>
<String>1 Leroy St</String>
<key>businessContent</key>
<String/>
<key>phoneNumber</key>
<String>(212) 242-3728</String>
<key>address</key>
<String>1 Leroy St</String>
<key>website</key>
<String/>
<key>category</key>
<int>0</int>
<key>refBusinessId</key>
<String>0</String>
<key>agreeCount</key>
<int>0</int>
<key>disagreeCount</key>
<int>0</int>
<key>relocatedListCount</key>
<int>0</int>
<key>notedListCount</key>
<int>0</int>
<key>userId</key>
<String>0</String>
<key>centerX</key>
<int>49822</int>
<key>centerY</key>
<int>23253</int>
</business>
</array>
</dict>