您的位置:首页 > 理论基础 > 计算机网络

IOS开发——HTTP请求

2014-03-11 13:51 295 查看
IOS开发——HTTP请求

 工具下载地址: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
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: