/*intercept a string to intercept a user name and password from the URL*/ 2NSString *str=@"Http://localhost:8090.cn?user=adminator&pwd=1234ABCD"; 3Nsrange range1=[str rangeofstring:@"user="]; 4Nsrange range2=[str rangeofstring:@"&pwd="]; 5Nsuinteger userlocation=range1.location+range1.length;6Nsuinteger userlength=range2.location-(range1.location+range1.length); 7Nsrange Userrange={userlocation,userlength};//Customizing a structure body range 8NSString *str1=[str substringwithrange:userrange];9NSLog (@"user=%@", str1);TenNsuinteger strlen=[str length]; OneNsuinteger pwdlocation=userlength+userlocation+range2.length; ANsuinteger pwdlength=strlen-(userlength+userlocation+range2.length); -Nsrange Pwdrange={pwdlocation,pwdlength};//Customizing a structure body range -NSString *str2=[str substringwithrange:pwdrange]; theNSLog (@"pwd=%@", str2);
oc--intercept string (user name and password are intercepted from URL)