I have this strange behavior where one of my category methods gets overridden when running on iPhone 3Gs with iOs 5.1.
I have this category:
@interface NSURL (queryParameters)
- (NSDictionary *) queryParameters;
@end
that returns a dictionary with NSString keys and NSArray values (multiple parameters with same name in my url).
It works fine except on the device mentioned above where I get an NSDictionary with NSString as values instead of the NSArray I was expecting (corresponding to last parameter in my url).
I created an empty project where I constructed a dummy NSURL and figured out that it responds to selector "queryParameters", and returns an NSDictionary with NSString as values:
NSString *urlString = @"http://dummy.url?foo=bar1&foo=bar2";
NSURL *url = [NSURL URLWithString:urlString];
NSLog(@"%@", [url respondsToSelector:@selector(queryParameters)]?@"YES":@"NO");
// YES
NSLog(@"%@", [[url performSelector:@selector(queryParameters)] debugDescription]);
// {
// foo = bar2;
// }
So I have 2 questions:
EDIT: According to this page iOS6-Private-Frameworks, this "queryParameters" is an undocumented method of NSURL (but that doesn't explain why in some case it was overridden).
Remark: I ended up renaming my own method to avoid this collision.
I think the convention here is also to prefix your category methods on classes that arent under your control to avoid any name clash!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With