URL转Dict

/// 把url解析成dict

- (NSDictionary*)handelUrl:(NSString *)strUrl;

{

NSMutableDictionary *mdict = [NSMutableDictionary dictionary];

NSArray *ary = [strUrl componentsSeparatedByString:@"&"];

for (NSInteger i = 1; i < ary.count; i++)

{

NSString *str= ary[i];

NSArray *ary = [str componentsSeparatedByString:@"="];

if (ary.count >= 2)

{

[mdict setValue:ary[1] forKey:ary[0]];

}

}

return [NSDictionary dictionaryWithDictionary:mdict];

}

你可能感兴趣的:(URL转Dict)