NSDictionary* headers; = [(NSHTTPURLResponse *)response allHeaderFields];
NSString *str;= [headers objectForKey:@"Www-Authenticate"];
NSLog(@"value:%@",str);
值:急救=“我的服务器部分”,qop =“接受”,nonce =“nyeraAT567WE”
我想要只打印nonce
答案 0 :(得分:1)
你需要一个正则表达式来提取它:
NSError *error=nil;
NSRegularExpression *regex = [[NSRegularExpression alloc] initWithPattern:@"nonce=\"(.*)\"" options:0 error:&error];
NSTextCheckingResult *match = [regex firstMatchInString:str options:0 range:NSMakeRange(0, [str length])];
NSString *nonce = [str substringWithRange:[match rangeAtIndex:1]];
NSLog(@"%@",nonce);