iOS nsstring Common string operations split lookup

Source: Internet
Author: User

1.NSString *str = [[NSString alloc]init]; Simple and rough, basically not used

2.NSString *str = [[NSString alloc]initwithformat:@ "xxx%@", str]; Favorite Common way.

3.NSString *str = [[NSString alloc]initwithstring:str];

4.NSString *str = [[NSString alloc]initwithnsdata: (NSData *) Encoding: (nsstringencoding)]; Convert encoding format

Note: encoding format:nsutf8stringencoding and so on.

nsdata* ext nsstring*: nsstring *< Span class= "PLN" >result = [[ Nsstring alloc] initwithdata : data  encoding:nsutf8stringencoding

NSString * Turn nsdata*:nsdata* xmlData = [@"testdata" datausingencoding: Nsutf8stringencoding];

5.[str ISEQUALTOSTRING:NSSTR]; Comparing strings

6.[str uppercasestring]; Capital

7.[str lowercasestring]; Lowercase

8.[str capitalizedstring]; Capitalize first letter

9.[string1 Rangeofstring:string2]; Character Wear Search

10.[string1 Substringtoindex:3]; Intercepts from the beginning of a string to the specified position, but not to the character at that position

11.[string1 Substringfromindex:3]; Starts at the specified position (including the character at the specified position) and includes all subsequent characters

12.[string1 substringwithrange:nsmakerange (0, 4)]; Arbitrarily intercept substrings from a string in the given position, length

13.NSString *str = @ "DD SS DD";

Nsarray *array = [str componentsseparatedbystring:@ "]; Split string

iOS nsstring Common string operations split lookup

Related Article

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.