Common usage of iOS strings

Source: Internet
Author: User

Creates a new string and sets it to the contents of the file specified by path, uses the character encoding enc, and returns an error on the error

+ (ID) Stringwithcontentsofurl: (nsurl *) URL encoding: (nsstringencoding) ENC error: (NSERROR *) error;

Creates a new string and sets it to the content specified by the URL, uses character encoding enc, and returns an error on the error
+ (ID) stringwithcontentsoffile: (NSString *) path encoding: (nsstringencoding) ENC error: (NSERROR *) error;

Create a new empty string

+ (ID) string

Creates a new string and sets its contents to the contents of a string

+ (ID) stringwithstring: (NSString *) string;

Set the newly assigned string to the contents of astring

-(ID) initwithstring: (NSString *) astring;

Set the string to the contents of the file specified by path using character encoding enc and returning an error on the error

-(ID) Initwithcontentsoffile: (NSString *) path encoding: (nsstringencoding) ENC error: (NSERROR *) error;

Set the string to the contents of the file specified by path using character encoding enc and returning an error on the error

-(ID) Initwithcontentsofurl: (nsurl *) URL encoding: (nsstringencoding) ENC error: (NSERROR *) error;

Returns the number of characters in a string

-(nsuinteger) length;

Returns the Unicode character where the index (a value, such as I) resides
-(Unichar) Characteratindex: (Nsuinteger) index;

Return from (?) Start to end substring

-(NSString *) Substringfromindex: (Nsuinteger) from;

Returns the position from the beginning of the string to the (?) Substring of
-(NSString *) Substringtoindex: (Nsuinteger) to;

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;

Test whether the string ends with astring

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

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.