澎湃iPad上线版本

topicModel.m 5.2KB

    // // topicModel.m // ThePaperBase // // Created by YoungLee on 15/8/26. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "topicModel.h" #define MYATTENTAG 1001 #define MYATTENNEXTURLTAG 1002 #define MYCREATETAG 1003 #define MYCREATENEXTURL 1004 @interface topicModel()<RemoteDelegate> @end @implementation topicModel -(void)setMyAttenDic:(NSMutableDictionary *)myAttenDic{ [Remote doJsonAction:MYATTENTAG requestUrl:myAttentionTopicListURL parameter:nil delegate:self]; } -(void)setMyAttenNextUrl:(NSString *)url{ [Remote doJsonAction:MYATTENNEXTURLTAG requestUrl:url parameter:nil delegate:self]; } -(void)setMyCreateDic:(NSMutableDictionary *)myCreateDic{ [Remote doJsonAction:MYCREATETAG requestUrl:myTopicListURL parameter:nil delegate:self]; } -(void)setMyCreateNextUrl:(NSString *)url{ [Remote doJsonAction:MYCREATENEXTURL requestUrl:url parameter:nil delegate:self]; } -(void)startWaitCursor:(int)actionTag{ } -(void)stopWaitCursor:(int)actionTag{ } -(void)remoteResponsSuccess:(int)actionTag withResponsData:(id)responsData{ if (MYATTENTAG ==actionTag) { [self saveMyAttenList:responsData]; }else if (MYCREATETAG == actionTag){ [self saveMyCreateList:responsData]; }else if (MYATTENNEXTURLTAG == actionTag){ [self saveMyAttenNextList:responsData]; }else if (MYCREATENEXTURL == actionTag){ [self saveMyCreateNextList:responsData]; } } -(void)remoteResponsFailed:(int)actionTag withMessage:(NSString *)message resultCode:(NSString *)code{ ShowTextMessage(message); if ([self.delegate respondsToSelector:@selector(returnNoData)]) { [self.delegate returnNoData]; } } -(void) saveMyAttenList:(id)responsData{ NSArray *topicTempList = responsData[@"topicList"]; NSMutableArray *topicArray = [NSMutableArray array]; [topicTempList enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { TopicInfoBO *topicInfo = setJsonDicToDataModel(obj, [TopicInfoBO class]); topicInfo.desc = obj[@"description"]; NSString *newNums = obj[@"newNums"]; if (newNums) { topicInfo.unNums = newNums; } [topicArray addObject:topicInfo]; }]; NSString *url = responsData[@"nextUrl"]; if ([self.delegate respondsToSelector:@selector(returnMyAttenList:url:)]) { [self.delegate returnMyAttenList:topicArray url:url]; } } -(void) saveMyCreateList:(id)responsData{ NSArray *topicTempList = responsData[@"topicList"]; NSMutableArray *topicArray = [NSMutableArray array]; [topicTempList enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { TopicInfoBO *topicInfo = setJsonDicToDataModel(obj, [TopicInfoBO class]); topicInfo.desc = obj[@"description"]; NSString *newNums = obj[@"newNums"]; if (newNums) { topicInfo.unNums = newNums; // if([topicInfo.status integerValue] == 1){ // topicInfo.unNums = newNums; // }else{ // topicInfo.unNums = @"0"; // } } [topicArray addObject:topicInfo]; }]; NSString *url = responsData[@"nextUrl"]; if ([self.delegate respondsToSelector:@selector(returnMyCreateList:url:)]) { [self.delegate returnMyCreateList:topicArray url:url]; } } -(void) saveMyAttenNextList:(id)responsData{ NSArray *topicTempList = responsData[@"topicList"]; NSMutableArray *topicArray = [NSMutableArray array]; [topicTempList enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { TopicInfoBO *topicInfo = setJsonDicToDataModel(obj, [TopicInfoBO class]); topicInfo.desc = obj[@"description"]; NSString *newNums = obj[@"newNums"]; if (newNums) { topicInfo.unNums = newNums; } [topicArray addObject:topicInfo]; }]; NSString *url = responsData[@"nextUrl"]; if ([self.delegate respondsToSelector:@selector(returnMyAttenNextList:url:)]) { [self.delegate returnMyAttenNextList:topicArray url:url]; } } -(void) saveMyCreateNextList:(id)responsData{ NSArray *topicTempList = responsData[@"topicList"]; NSMutableArray *topicArray = [NSMutableArray array]; [topicTempList enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { TopicInfoBO *topicInfo = setJsonDicToDataModel(obj, [TopicInfoBO class]); topicInfo.desc = obj[@"description"]; NSString *newNums = obj[@"newNums"]; if (newNums) { topicInfo.unNums = newNums; // if([topicInfo.status integerValue] == 1){ // topicInfo.unNums = newNums; // }else{ // topicInfo.unNums = @"0"; // } } [topicArray addObject:topicInfo]; }]; NSString *url = responsData[@"nextUrl"]; if ([self.delegate respondsToSelector:@selector(returnMYCreateNextUrl:url:)]) { [self.delegate returnMYCreateNextUrl:topicArray url:url]; } } @end