加班~~~第三天之添加自定义方法

来源:互联网 发布:matlab结构矩阵 编辑:程序博客网 时间:2024/06/10 14:18
<span style="font-family: Arial, Helvetica, sans-serif;">+ (NSMutableDictionary *)addReplyCountNumber:(NSDictionary *)helpBroadDic</span>
{    if(helpBroadDic == nil || [helpBroadDic count] == 0)        return nil;    if([helpBroadDic objectForKey:kHelpBroadType] == nil)    {        NSInteger count = 0;        NSMutableDictionary *helpDic = [[[NSMutableDictionary alloc] initWithDictionary:helpBroadDic] autorelease];        if ([helpDic objectForKey:kHelpAnswerCountKey])        {            count = [[helpDic objectForKey:kHelpAnswerCountKey] integerValue];        }        count ++;        [helpDic setObject:[NSString stringWithFormat:@"%d",count] forKey:kHelpAnswerCountKey];        return helpDic;    }    NSInteger helpType = [[helpBroadDic objectForKey:kHelpBroadType] integerValue];    if (helpType == 1)    {         NSDictionary *helpBroad = nil;        if([[helpBroadDic objectForKey:kHelpBroadKey] isKindOfClass:[NSArray class]])        {            NSArray *arr = [helpBroadDic objectForKey:kHelpBroadKey];            if([arr count] > 0)            {                helpBroad = [arr objectAtIndex:0];                NSInteger count = 0;                NSMutableDictionary *helpDic = [[NSMutableDictionary alloc] initWithDictionary:helpBroad];                if ([helpDic objectForKey:kHelpAnswerCountKey])                {                    count = [[helpDic objectForKey:kHelpAnswerCountKey] integerValue];                }                count ++;                [helpDic setObject:[NSString stringWithFormat:@"%d",count] forKey:kHelpAnswerCountKey];                NSMutableArray *helpArray = [[NSMutableArray alloc] initWithCapacity:0];                [helpArray addObject:helpDic];                [helpDic release];                NSMutableDictionary *helpBroadDicMuti = [[[NSMutableDictionary alloc] initWithDictionary:helpBroadDic] autorelease];                [helpBroadDicMuti setObject:helpArray forKey:kHelpBroadKey];                [helpArray release];                return helpBroadDicMuti;            }        }        else if ([[helpBroadDic objectForKey:kHelpBroadKey] isKindOfClass:[NSDictionary class]])        {            helpBroad = [helpBroadDic objectForKey:kHelpBroadKey];            NSInteger count = 0;            NSMutableDictionary *helpDic = [[NSMutableDictionary alloc] initWithDictionary:helpBroad];            if ([helpDic objectForKey:kHelpAnswerCountKey])            {                count = [[helpDic objectForKey:kHelpAnswerCountKey] integerValue];            }            count ++;            [helpDic setObject:[NSString stringWithFormat:@"%d",count] forKey:kHelpAnswerCountKey];            NSMutableDictionary *helpBroadDicMuti = [[[NSMutableDictionary alloc] initWithDictionary:helpBroadDic] autorelease];            [helpBroadDicMuti setObject:helpDic forKey:kHelpBroadKey];            [helpDic release];            return helpBroadDicMuti;        }            }    return [NSMutableDictionary dictionaryWithDictionary:helpBroadDic];}
 重点看思路吧   思路很重要哈
0 0