View Full Version : String to ascii conversion, xor it with another integer. Objective-C

Mar 30, 2011, 10:38 PM
Hello, I have a string from which using for-loop ,each char has been converted into ascii and then xored with an integer. I converted each output back to its relevant char. I need to print all those output characters all at once on the label field in the iphone GUI.

I not able to get the part where I need to print them all onto the label field. Here is the code. Any help is appreciated. Thanks in advance

-(IBAction)result {

NSString *str = [[NSString alloc] initWithFormat:@"%@", [sword text]];

for ( NSInteger i=0; i<[str length]; i++ )
unichar c = [str characterAtIndex:i];

int asciiCode1 = ([kword.text intValue]);

int z = asciiCode1 ^ c;

int a = (char)z;
label.text = [NSString stringWithFormat:@" %c", a];

Mar 30, 2011, 10:57 PM
Posting the same question on different forums at the same time is considered rude, Rahul. I'm sure you think your time is valuable. So does everyone else.

Mar 30, 2011, 11:19 PM
I am quiet new to using forums and dint know that the users would be common. I apologize for that.

Mar 31, 2011, 12:07 AM
IMO, it's reasonable to make a second post to another forum after a reasonable time with no good response. Like 24 hours.

People take time to write their responses. It's not fair to have people take time to respond if you've already gotten a response in another forum. And if there are multiple responses on one forum those readers on the other forum probably won't see them.

Anyway, you've gotten a response on the other forum.

Mar 31, 2011, 01:29 AM
When posting code that doesn't compile, say "It doesn't compile", and provide the exact text of the error message, preferably by copy and pasting it.