1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

String to ascii conversion, xor it with another integer. Objective-C

Discussion in 'iPhone/iPad Programming' started by xcoder1987, Mar 30, 2011.

  1. xcoder1987, Mar 30, 2011
    Last edited by a moderator: Mar 30, 2011

    macrumors newbie

    #1
    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

    Code:
    -(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];
     
  2. macrumors 68030

    PhoneyDeveloper

    #2
    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.
     
  3. macrumors newbie

    #3
    I am quiet new to using forums and dint know that the users would be common. I apologize for that.
     
  4. macrumors 68030

    PhoneyDeveloper

    #4
    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.
     
  5. macrumors 603

    #5
    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.
     

Share This Page