/dictionary or array into nsstring
Nsarray *arr = [Nsarray arraywithobject:@ "1"];
NSString *str = [arr jsonstring]; Convert an array or dictionary into a JSON string
Nsarray *arr1 = [str objectfromjsonstring]; JSON string into a dictionary or array
NSData *data = [arr1 jsondata]; Convert the JSON string to NSData
NSString *STR1 = [[NSString alloc] initwithdata:data encoding:nsutf8stringencoding];//switch NSData to NSString
NSData *data1 = [str1 datausingencoding:nsutf8stringencoding]; Turn the nsstring into a nsdata
Binary flow becomes string
NSString *str=[[nsmutablestring alloc] initWithData:self.receiveDataencoding:NSUTF8StringEncoding];
Change the content
Str=[str stringbyreplacingoccurrencesofstring:@ "," withstring:@ ", \ n"];
Str=[str stringbyreplacingoccurrencesofstring:@ "{" withstring:@ "{\ n"];
Str=[str stringbyreplacingoccurrencesofstring:@ "}" withstring:@ "\ n}"];
NSLog (@ "%@", str);
Convert a string into a binary stream
Self.receivedata=[nsmutabledata Datawithdata:[str Datausingencoding:nsutf8stringencoding]];
Request changed to URL
Nsurl *url=[request URL];
URL changed to NSString
NSString *str=[[url absolutestring] stringbyreplacingpercentescapesusingencoding:nsutf8stringencoding];
NSLog (@ "%@", str);
Nsurl *url=[nsurl urlwithstring:@ "Http://img3.xooimage.com/files/6/1/3/firefox-logo-200x200-19f78a.png"];
Web site into a binary stream
Nsmutabledata *data=[nsmutabledata Datawithcontentsofurl:url];
UIImage *image=[uiimage Imagewithdata:data];
Read file
NSString *filepath = [[NSBundle mainbundle] pathforresource:@ "Students" oftype:@ "xml"];
File into a binary stream
NSData *data = [NSData Datawithcontentsoffile:filepath];
Take out the first letter
NSString *name = [City objectforkey:@ "name"];
NSString *firststr=[name substringwithrange:nsmakerange (0, 1)];
Remove an array directly from a string
NSString *str = [NSString stringwithformat:@ "Norman,stanley,fletcher"];
Nsarray *arr = [str componentsseparatedbystring:@ ","];
NSLog (@ "arr =%@", arr);
transcoding
URLSTR = [Urlstr stringbyaddingpercentescapesusingencoding:nsutf8stringencoding];
Tips for translating iOS development strings