I have an NSURL:
serverCall?x=a&y=b&z=c
What is the quickest and most efficient way to get the value of y?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
UPDATE:
Since 2010 when this was written, it seems Apple has released a set of tools for that purpose. Please see the answers below for those.
Old-School Solution:
Well I know you said “the quickest way” but after I started doing a test with
NSScannerI just couldn’t stop. And while it is not the shortest way, it is sure handy if you are planning to use that feature a lot. I created aURLParserclass that gets these vars using anNSScanner. The use is a simple as:And the class that does this is the following (*source files at the bottom of the post):
URLParser.h
URLParser.m
*if you don’t like copying and pasting you can just download the source files – I made a quick blog post about this here.