iOS URL 参数分离
2020-04-24 本文已影响0人
一万次番茄炒蛋
记一手URL参数分离代码
NSString *scanResult = [scanResultQRcode stringByRemovingPercentEncoding];
NSURLComponents *urlComponents = [[NSURLComponents alloc] initWithString:scanResult];
NSArray *results = urlComponents.queryItems;
@interface NSURLQueryItem : NSObject <NSSecureCoding, NSCopying> {
@private
NSString *_name;
NSString *_value;
}
取数组中的NSURLQueryItem对象即可拿到想要的参数