Convert NSMutableData to NSString

Discussion in 'iOS Programming' started by arme, Sep 24, 2008.

  1. arme macrumors member

    Joined:
    Sep 15, 2008
    #1
    NSString *tmp = [[NSString alloc] initWithData:receivedData encoding:UTF8Char];

    Error before encoding .
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    As we are not mind readers could you post the error? And anything else relevant?
     
  3. arme thread starter macrumors member

    Joined:
    Sep 15, 2008
    #3
    I receive a request from url. that is a string( OK or NOK) .it is save in NSSMUutableData . i need convert to NSString. have are you a idea?
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    I know what you are trying to do. You've posted about it over and over and over and over and over and over and over and....

    You say "Error before encoding". What is the error. Unless you are willing to post questions with enough detail you are not going to get answers.
     
  5. arme thread starter macrumors member

    Joined:
    Sep 15, 2008
    #5
    error message is syntax error before encoding.
    and the remind of code is correct.
    please give me an idea that solve converting?
    thanks
     
  6. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    Then you have typed something incorrectly somewhere. Not necessarily on that line: you may have forgotten a ; or a ] somewhere else.

    In my own code I'm using this (not sure why I chose this method over that one):

    Code:
    NSString *sourceSt = [[NSString alloc] initWithBytes:[downloadedData bytes] length:[downloadedData length] encoding:NSUTF8StringEncoding];
    
     
  7. arme thread starter macrumors member

    Joined:
    Sep 15, 2008

Share This Page