开发小技巧(持续更新)
2020-05-18 本文已影响0人
iPhone贴膜小哥
从URL中提取参数为字典:
+ (NSDictionary *)_parameterWithURL:(NSURL *)url {
NSMutableDictionary *params = [[NSMutableDictionary alloc]init];
NSURLComponents *urlComponents = [[NSURLComponents alloc] initWithString:url.absoluteString];
[urlComponents.queryItems enumerateObjectsUsingBlock:^(NSURLQueryItem * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
[params setObject:obj.value forKey:obj.name];
}];
return params;
}