iOS URL参数转字典
+(NSDictionary *) parameterWithURL:(NSURL *) url {
NSMutableDictionary *parm = [[NSMutableDictionary alloc]init];
//传入url创建url组件类
NSURLComponents *urlComponents = [[NSURLComponents alloc] initWithString:url.absoluteString];
//回调遍历所有参数,添加入字典
[urlComponents.queryItems enumerateObjectsUsingBlock:^(NSURLQueryItem * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
[parm setObject:obj.value forKey:obj.name];
}];
return parm;
}
本文标题:iOS URL参数转字典
本文链接:https://www.haomeiwen.com/subject/ibvuzrtx.html
网友评论