iphone ios http非同期操作
5174 ワード
以下の友情サポートをお願いします。
一つの製品を作ったら、人気が必要です。アンディロイドとiphoneで91の市場検索をします。http://m.ixingji.com/m.html?p=X16みんなでお世辞を言っています。
同期
一つの製品を作ったら、人気が必要です。アンディロイドとiphoneで91の市場検索をします。http://m.ixingji.com/m.html?p=X16みんなでお世辞を言っています。
同期
NSString* urlString = [URLMake makePrepareUploadVideo:[AccountInfo getAccountInfo].uid
token:[AccountInfo getAccountInfo].token
folderid:@"-1"
filepath:[self getUploadServerRelativePath:item]
sha1:self.sha1
size:[videoFileOp fileSize]
upchannel:@"2"
tryTimes:reTryTimes
filename:filename
intro:item.uploadFile.description
suffix:ext
timestamp:item.uploadFile.createTime
latitude:item.uploadFile.latitude
longitude:item.uploadFile.longitude];
//[videoFileOp release];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:urlString]];
[request startSynchronous];
if( [request responseStatusCode] == 403 ){
ret = NO;
}else{
NSError *error = [request error];
if (!error) {
NSData *data = [request responseData];
if (data && [JsonParser checkJsonResult:data] == 200) {
ret = [self parsePrepareUploadXml:data uploadItem:item];
if (!ret) {
if (item.uploadStatus == kUploadStatusUploadSpaceNotEnough) {
ret = NO;
}else if (item.uploadStatus == kUploadStatusUploadHadUploaded){
ret = NO;
DLog(@" , id=%@", item.uploadFile.fid);
item.uploadCompleted = YES;
}
}
}
}
}
非同期-(void)downloadFiles:(BOOL)update
{
NSString *url = nil;
NSDictionary* dictionary = nil;
if (update) {
url = [URLMake makeHotBackGirlUrl:0 getNum:MAX_GETLIST_NUM uid:[AccountInfo getAccountInfo].uid token:[AccountInfo getAccountInfo].token];
dictionary = [NSDictionary dictionaryWithObjectsAndKeys:ft_BeautyGirlListJson, ft_Key, (update?@"update":@"more")
, @"updateType",nil];
}else {//
//BackGirlInfo *girlInfo = [self.resultList lastObject];
url = [URLMake makeHotBackGirlUrl:self.resultList.count getNum:MAX_GETLIST_NUM uid:[AccountInfo getAccountInfo].uid
token:[AccountInfo getAccountInfo].token];
dictionary = [NSDictionary dictionaryWithObjectsAndKeys:ft_BeautyGirlListJson, ft_Key, (update?@"update":@"more")
, @"updateType",nil];
}
[self requestDataFromURL:url userInfo:dictionary];
}
- (void)requestFinished:(ASIHTTPRequest *)request
{
NSString *dataType = [request.userInfo objectForKey:ft_Key];
NSData* data = [request responseData];
if (data.length > 0) {
if ([dataType isEqualToString:ft_BeautyGirlListJson]) {
BackGirlListParser *backGirlListParser = [[BackGirlListParser alloc] initWithData:data];
if ([backGirlListParser parser]){
if ([[request.userInfo objectForKey:@"updateType"] isEqualToString:@"update"]) {
self.resultList = backGirlListParser.resultList;
NSString *path = path = [CachePathMake makeMainBeautyCachePath];
[CommonFun createDirectoryIfNeeded:path];
[data writeToFile:path atomically:YES];
}else{
[self mergeResultList:backGirlListParser.resultList];
}
[self showMoreFooterView:backGirlListParser.resultList.count >= MAX_GETLIST_NUM?YES:NO];
if(backGirlListParser.resultList.count > 0){
[self initQueenGirlPhoto];
[[self getTargetTableView] reloadData];
}
[self doneLoadingTableViewHeaderData];
}else{
[self doneLoadingTableViewHeaderData];
}
[backGirlListParser release];
}else {
[super requestFinished:request];
}
}
}