提取url参数?

时间:2011-07-20 15:37:46

标签: iphone objective-c url parameters

  

可能重复:
  Parse NSURL query property

我有这样的网址:

someapp://#=的access_token 1234%d&安培; refresh_token = 54%d%D321&安培; instance_url = HTTPS%3A%2F%2Fsf.com

我想提取这些url参数以获得这样的字典:

access_token:1234 =

refresh_token:54 == 321

instance_url:https://sf.com

我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

尝试:

NSString *url = @"someapp://#access_token=1234%D&refresh_token=54%D%D321&instance_url=https%3A%2F%2Fsf.com";

NSarray *chunks = [url componentSeparatedBy:@"="]; // OR "?/&/etc"
NSLog("%@", chunks);