Escape Quotes in Objective-C

后端 未结 4 1989
Happy的楠姐
Happy的楠姐 2020-12-10 16:52

I\'m using this code snippet to encode characters to be friendly with a POST request:

   NSString *unescaped = [textField text];
   NSString *escapedString =         


        
4条回答
  •  被撕碎了的回忆
    2020-12-10 17:22

    I think I didn't word the question correctly.

    I needed to take the user inputted NSString from [textField text] and make sure that if there are quotation marks in the string, they are escaped properly in order to send through a POST statement.

    My solution was:

    unescaped = [unescaped stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""];
    

    Thanks

提交回复
热议问题