today is self-study, a few days ago to play the game in the teacher's lead to do it again, and today reviewed again, and then try to do a simple angrybird, in the process found some small problems, sometimes easy sloppy, less a line of code, a return or a initialization But it will take a long time to check out, really should not, after sloppy once, put the wrong place on the note and in the heart silently back 10 times, after the wrong still, I think it should be very effective to avoid repeating it. Recently still feel limited, a lot of ideas can not be achieved or to achieve a very troublesome, this will become my motivation to learn, I hope to see the current log can be a smile, in the heart silently tell yourself: you insisted on down, now do! because the use of nsstring before learning some unfamiliar, so take advantage of today's self-study and read again, and finally briefly summed up.
nsstring Basic Usage1. Write a string into the Make foldernsstring *mystring = @ "Rongtiantext–intexnet";Nserror *error;nsstring *path = [Nshomedirectory () stringbyappendingpathcomponent:@ "Tmp/rongtian.txt"];if (![ MyString writetofile:path atomically:yes encoding:nsutf8stringencoding Error:&error]) {NSLog (@ "Write file error%@", error);return; }2.NSString RangeNsrange R;r.location = 4;r.length = 5;nsstring *strsub = [str substringwithrange:r];NSLog (@ "Range%@", strsub);3. Searchnsrange searchrange = [str rangeofstring:@ "Five"];if (searchrange.location! = nsnotfound) {NSLog (@ "Search location%d%d", searchrange.location,searchrange.length); }4. Replacensstring *replaced = [str stringbyreplacingoccurrencesofstring:@ "" withstring:@ "+"];NSLog (@ "replaced file%@", replaced);
Lan Yi iOS Training log 2 review nsstring basic usage and practice experience Liu Guobin Teacher