Lan Yi iOS Training log 2 review nsstring basic usage and practice experience Liu Guobin Teacher

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.