I am pulling in the components from a NSURL
using componentswithurl:
resolvingagainstbaseurl:
. This gives me an NSArray
of query items, but I cannot get the value for each object out of the array based on the key. I am doing this for a custom url that is launching my app from another app. I am doing something like:
Incoming url: something://init?item1=xxxx&item2=yyy&item3=www2&item4=sss
NSURLComponents *comp = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:true];
NSAray *compDict = comp.queryItems;
Thus giving me a list of object with a key value pair.
compDict[0] =
name = item1
value = xxxx
and so on. I am trying to get the value based on the name(key) using:
NSString *value = [compDict valueForKey:@"item1"];
but this gives me an error - [<NSURLQueryItem> valueforundefinedkey:]this class is not key value coding-compliant for key item1
.
Can someone help me out on this.