Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Convert HTML string to Plane NSString

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.26k
    Comment on it

    Hi Friends,
    Sometime in API responses we get html strings.
    To get pure string from html string this code will help you.

    NSString *htmlStr = @"html String";
        NSData *data = [htmlStr dataUsingEncoding:NSUTF8StringEncoding];
    
        NSDictionary * dict = @{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType};
        NSAttributedString *decodedString;
        decodedString = [[NSAttributedString alloc] initWithData:data
                                                         options:dict
                                              documentAttributes:nil
                                                           error:nil];
    

    Happy coding..

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: