ios - Send a request with automatic encoding -


I am sending a request like this:

  self.message = [self. Message Stringerling Occurrence Offstring: @ "& amp;" WithString: @ "§§§§"]; Self.message = [self. Message string barrier reeling ocronsoffstring: @ "'" with string: @ "- $ -"]; Self.message = [Self. Message string bearerening occurenceoffstring: @ "+" with string: @ "- & lt; # -"]; NSString * post = [NSString stringWithFormat: @ "id_user =% @ & amp; Message =% @ & amp; mode =% @ & amp; list_id =% @ and date_expired =% @ and Antrpraijh_ id =% @", id_user, self Messages, etc. ObjectForKey: @ "id_enterprise"]]; NSDTA * PostData = [Encoding to Use Data: NSUFF 8 string encoding permission; Lossy conversion: Yes]; NSString * postLength = [NSString stringWithFormat: @ "% lu", (unsigned long) [postdata length]]; NSMutableURLRequest * Request = [[NSMutableURLRequest alloc] init]; // etc   

So, why am I using stringburease? Because if '' '' or '& amp;' , Then it can cause some problems like ID_User = IZDs and TOI and message like URL. It seems that it will conflict with; for example.

So I wonder if there is a problem or this problem can be solved, anything other than that?

Use this method Pass your urlString with this method.

  + (NSString *) urlEncodeValue: (NSString *) str {if (str == null) {return @ ""; } NSString * result = (__Bridge_transfer NSString *) CFURLCreateStringByAddingPercentEscapes (kCFAllocatorDefault, (__Briff CFStringRef) str, NULL, CFSTR ( "! * '\" () :: @ & Amp; = + $, /?% # []% " ), KCFStringEncodingUTF8); return result;}    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -