0

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!

3
  • Are firstId and secondId of NSString type? Commented Oct 13, 2011 at 14:52
  • firstId is NSString but secondId is not! Commented Oct 13, 2011 at 14:53
  • ifrstId is an NSString?? Commented Oct 13, 2011 at 15:01

1 Answer 1

1

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];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.