IOS开发——HTTP请求
2014-03-11 13:51
295 查看
IOS开发——HTTP请求
工具下载地址:http://download.csdn.net/detail/u012881779/7022403
项目笔记,参考, 本文介绍使用方法:
生成JSON数据部分:
工具下载地址:http://download.csdn.net/detail/u012881779/7022403
项目笔记,参考, 本文介绍使用方法:
生成JSON数据部分:
#import<Foundation/Foundation.h> #import"DMUserModel.h" #import"SBJson.h" #import"DMAppearObserveModel.h" #import"DMPictureNewsModel.h" #import"DMImageInfoModel.h" @interfaceDMJSONCreate : NSObject //USer生成JSON格式 +(NSString*)gmJSONWithModel:(DMUserModel * )theModel; //爆料 +(NSString *)gmJSONPictureNewsWithModel:(DMPictureNewsModel*)theModel; @end #import "DMJSONCreate.h" @implementation DMJSONCreate //User生成JSON格式 +(NSString *)gmJSONWithModel:(DMUserModel * )theModel{ NSString *returnStr = nil; NSMutableDictionary *dict =[[NSMutableDictionary alloc]initWithObjectsAndKeys: theModel.ymPassword,@"Password", theModel.ymNickName,@"NickName", theModel.ymStfCode,@"StfCode", theModel.ymUserName,@"UserName", theModel.ymGender,@"Gender", theModel.ymDeptId,@"DeptId", theModel.ymNativePlace,@"NativePlace", theModel.ymPosId,@"PosId", theModel.ymSuperId,@"SuperId", theModel.ymEducation,@"Education", theModel.ymWorkExp,@"WorkExp", theModel.ymBornDate,@"BornDate", theModel.ymJoinDate,@"JoinDate", theModel.ymCountryId,@"CountryId", theModel.ymQQ,@"QQ", theModel.ymBranchId,@"BranchId", theModel.ymMail,@"Mail", theModel.ymTelePhone,@"TelePhone", theModel.ymTelePhoneExt,@"TelePhoneExt", theModel.ymMobilePhone,@"MobilePhone", theModel.ymSafeQuestion,@"SafeQuestion", theModel.ymSafeAnswer,@"SafeAnswer", theModel.ymZip,@"Zip", theModel.ymAddress,@"Address", theModel.ymRemark,@"Remark", theModel.ymStatusId,@"StatusId", theModel.ymPhoto,@"Photo", theModel.ymIdentityCard,@"IdentityCard", theModel.ymOnlineStatusId,@"OnlineStatusId", theModel.ymIP,@"IP", theModel.ymCityId,@"CityId", theModel.ymTownId,@"TownId", theModel.ymPowerId,@"PowerId", theModel.ymPowerStartDate,@"PowerStartDate", theModel.ymPowerEndDate,@"PowerEndDate", nil]; SBJsonWriter *writer = [[SBJsonWriter alloc]init]; returnStr = [writer stringWithObject:dict]; return returnStr; } //爆料 +(NSString *)gmJSONPictureNewsWithModel:(DMPictureNewsModel*)theModel{ NSString *returnStrP = nil; //图组,图片属性 NSMutableArray *tempImageArr =[[NSMutableArrayalloc] init]; for(DMImageInfoModel *tempImageModelintheModel.ymImageList){ NSMutableDictionary*dictImageList = [[NSMutableDictionary alloc] initWithObjectsAndKeys: [NSStringstringWithFormat:@"%d",tempImageModel.ymContentid],@"Comtentid", tempImageModel.ymDescription,@"description", tempImageModel.ymFrURL,@"FrURL", tempImageModel.ymPublished,@"Published" , nil]; [tempImageArr addObject:dictImageList]; } //爆料新闻 NSMutableDictionary *dict =[[NSMutableDictionary alloc]initWithObjectsAndKeys: theModel.ymTitle,@"title", theModel.ymModelid,@"modelid", theModel.ymCatid,@"catid", theModel.ymDescription,@"description", theModel.ymSource,@"Source", theModel.ymContent,@"Content", theModel.ymVideo,@"Video", theModel.ymPlaytime,@"Playtime", theModel.ymTopicid,@"topicid", theModel.ymPublished,@"published", theModel.ymThumb,@"thumb", theModel.ymComments,@"comments", tempImageArr,@"Imagelist", nil]; SBJsonWriter *writer = [[SBJsonWriter alloc]init]; returnStrP = [writer stringWithObject:dict]; return returnStrP; } @end
相关文章推荐
- 【iOS开发】使用Paros监控iPhone发出的HTTP请求
- iOS开发中如遇到频繁的Http请求,如何取消之前已经发送的Http请求?
- iOS开发经验技巧之IOS中http请求使用cookie
- iOS开发——网络基础、iOS常用http请求、URL编码
- IOS开发笔记_5.线程,HTTP请求,定时器
- iOS开发中如遇到频繁的Http请求,如何取消之前已经发送的Http请求?
- iOS开发--http请求设置Cookie
- 【iOS开发】使用Paros监控iPhone发出的HTTP请求
- iOS 开发 中级:HTTP请求 GET POST 网络编程实现
- ios开发如何封装AFN第三方类库中的http请求
- iOS 开发 中级:HTTP请求 GET POST 网络编程实现
- iOS开发中如遇到频繁的Http请求,取消之前已经发送的Http
- IOS开发:ASIHTTPRequest中HTTP请求终结者详解
- [Phonegap+Sencha Touch] 移动开发65 iOS 9 (XCode 7) 上架之前需要做的几个步骤(解决不能联网,http请求失败)
- iOS开发 取消之前已经发送的Http请求
- iOS 开发 中级:HTTP请求 GET POST 网络编程实现
- iOS开发-HTTP请求
- IOS开发:ASIHTTPRequest中HTTP请求终结者详解
- iOS 开发 中级:HTTP请求 GET POST 网络编程实现
- IOS开发笔记_5.线程,HTTP请求,定时器