开发者

How do I send multiple querystring parameters in ios?

开发者 https://www.devze.com 2023-04-12 15:20 出处:网络
Here is my code Passing parameters to my Querystring gives me Bad Access Error! NSString *myJson = @\"http://mySite.com/Service.svc/MyList\"开发者_如何转开发;

Here is my code

Passing parameters to my Querystring gives me Bad Access Error!

NSString *myJson = @"http://mySite.com/Service.svc/MyList"开发者_如何转开发;
myJson = [myJson stringByAppendingFormat:@"?id=%@&uid=%@", firstId, secondId];

Can someone help me out!


What you do here is simple string formatting.

Given what you are doing, I guess firstId & secondId are integers, not objects, so your error is because you don't use the right format.

The format %@ in you stringByAppendingFormat is for displaying an object, or more precisely the string returned by its description selector.

If you want to format an integer, just use %d as in C :)

This will give you :

NSString *myJson = @"http://mySite.com/Service.svc/MyList";
myJson = [myJson stringByAppendingFormat:@"?id=%d&uid=%d", firstId, secondId];
0

精彩评论

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

关注公众号