Common methods for NSString strings

Source: Internet
Author: User

Returns a substring based on a specified range
-(NSString *) Substringwithrange: (nsrange) range;

Compare two strings (ignoring case)

-(Nscomparisonresult) Caseinsensitivecompare: (NSString *) string;

Comparison of two strings

-(Nscomparisonresult) Localizedcompare: (NSString *) string;

Test whether the string starts with astring

-(BOOL) Hasprefix: (NSString *) astring;//this more commonly used

Test whether the string ends with astring

-(BOOL) Hassuffix: (NSString *) astring;//This is also more commonly used

Tests whether two strings are equal

-(BOOL) isequaltostring: (NSString *) astring;

Returns the first letter of each word in string strings, with the remaining letters lowercase

-(NSString *) capitalizedstring;

Returns a string converted to lowercase

-(NSString *) lowercasestring;

Returns a string converted to uppercase

-(NSString *) uppercasestring;

Returns a string converted to UTF8 encoded format

-(__strong const char *) utf8string;

Returns a string that converts a double type

-(double) doublevalue;

Returns a string that converts a float type

-(float) floatvalue;

Returns a string that converts the type int

-(int) intvalue;

Returns a string converted to the Nsinteger type

-(Nsinteger) IntegerValue

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.