How to take the parameter from URL scheme.

前端 未结 3 1096
死守一世寂寞
死守一世寂寞 2021-02-06 17:49

I am using URL scheme in my iPhone app,from a page I switch user to safari,and a button click from Web page,I am reverting back to app At that time ,some parameters are passed b

3条回答
  •  感情败类
    2021-02-06 18:13

    Try this code. this ll useful even if you had numbers of parameters and values in url.

    NSURL *url = [NSURL URLWithString:@"xyz.com/result.php?data1=1123660801&data2=250072028055&presult=SUCCESS"];
    
    NSURLComponents *components = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO];
    NSArray *queryItems = [components queryItems];
    
    NSMutableDictionary *dict = [NSMutableDictionary new];
    
    for (NSURLQueryItem *item in queryItems)
    {
        [dict setObject:[item value] forKey:[item name]];
    }
    

提交回复
热议问题