views:

59

answers:

2

I'm having a problem trying to convert a character into a string in Xcode. Here's my code...

NSString *temp = [NSString stringWithFormat:@"%@  %@  %@ = %@", inputOne.text, sign.text, inputTwo.text, answer.text];

self.sign.text is supposed to return either a "+", "-", "*", or "/", which it does. However, I'm trying to have the user post one of these back into facebook via the app. All but the "+" sign will load as a string when they post it to their wall. I don't understand how to get the "+" to show.

I'm guessing that this gets lost since the "+" has a different meaning in javascript. How can I make it a string character in my NSString so that it accepts when posting. Hope this made sense.

A: 

I know you can put a quotation mark into a textView by placing a "\" before the quotation. This may work with a "+" sign as well. So the string would look something like this:

@"This is a plus sign \+ in a textView"

Which would return

This is a plus sign + in a textView
Jonah
I'm trying to publish feeds to facebook. The \+ key didn't work.http://github.com/facebook/facebook-iphone-sdkLook at the section there on Publishing Feed Stories. I need to it to show this "1/2 + 1/2 = 1 or 1/1". That's just a sample, but I want it to show the plus sign.
Jrman52
A: 

Sending "+" over the net (e.g. in GET or, I think, POST) will convert "+" into a space character. To fix, you need to escape the "+" using "%2B".

Kalle
Tried doing that, didn't work.
Jrman52
You're still getting a space? Uh, how about %252B? That's "%" encoded plus 2B which becomes "%2B" which is "+"... Without digging into the framework, or seeing what your results look like, I can only guess away. :)
Kalle
I figured it out. It was %%2B. I had to use double percentages. Thanks for the help guys :)
Jrman52
Glad you figured it out.
Kalle