开发者

How to concatenate an nsstring url

开发者 https://www.devze.com 2023-02-27 06:47 出处:网络
How can I concatenate an NSString URL? For example: http://isomewebsite.com/username开发者_开发技巧=[someuservariable]&password=[somevariable]

How can I concatenate an NSString URL? For example:

http://isomewebsite.com/username开发者_开发技巧=[someuservariable]&password=[somevariable]


Try with below code.

NSString* myURLString = [NSString stringWithFormat:@"somewebsite.com/username=%@&password=%@", myUserName,myPassword];
NSURL *url = [NSURL URLWithString:myURLString];

Here is the blog tutorial will help you know more about Handling url authentication challenges accessing password protected servers


You can use the method stringWithFormat of NSString:

NSString *url = [NSString stringWithFormat:@"somewebsite.com/username=%@&password=%@", someuservariable, some variable];


Try this excellent post - URL encoding an NSString on iOS

0

精彩评论

暂无评论...
验证码 换一张
取 消