美文网首页
URL转Dict

URL转Dict

作者: 大鹏你我他 | 来源:发表于2017-05-15 11:40 被阅读0次

    /// 把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

          本文链接:https://www.haomeiwen.com/subject/rlfhxxtx.html