Wenn ich ein Abfrageelement hinzufügen, dann ändert NSURLComponents% 2B in +, während% 7B unverändert bleibt. Von meinem Verständnis her sollte es entweder "+" und "{" dekodieren, warum dekodiert es nur einen von ihnen?NSURLComponents ändert% 2B in + beim Hinzufügen einer neuen Abfrage Element
NSString *urlString = @"http://www.example.com?a=%7B1%2B2%7D";
NSURLComponents *components = [NSURLComponents componentsWithString:urlString];
NSLog(@"%@",components);
// <NSURLComponents 0x7ffc42c19d40> {scheme = http, user = (null), password = (null), host = www.example.com,
// port = (null), path = , query = a=%7B1%2B2%7D, fragment = (null)}
NSURLQueryItem *queryItem = [NSURLQueryItem queryItemWithName:@"hl" value:@"en-us"];
components.queryItems = [components.queryItems arrayByAddingObject:queryItem];
NSLog(@"%@",components);
// <NSURLComponents 0x7ffc42c19d40> {scheme = http, user = (null), password = (null), host = www.example.com,
// port = (null), path = , query = a=%7B1+2%7D&hl=en-us, fragment = (null)}
Dies ist ein tatsächlich bestehendes Problem, ich weiß nicht, warum das downvotes? – ooops