IOS Study Notes-common NSString Methods

Source: Internet
Author: User


Create a new string and set it to the content of the file specified by path. Use the character encoding enc to return an error on error.


+ (Id) stringWithContentsOfURL :( NSURL *) url encoding :( NSStringEncoding) enc error :( NSError **) error;



Create a new string and set it to the content specified by the url. Use the character encoding enc to return an error on error.


+ (Id) stringWithContentsOfFile :( NSString *) path encoding :( NSStringEncoding) enc error :( NSError **) error;



Create a new Null String


+ (Id) string

Create a new string and set its content to string
+ (Id) stringWithString :( NSString *) string;



Set the new string to astring.

-(Id) initWithString :( NSString *) aString;



Set the string to the content of the file specified by path using the character encoding enc, and return an error on error

-(Id) initWithContentsOfFile :( NSString *) path encoding :( NSStringEncoding) enc error :( NSError **) error;



Set the string to the content of the file specified by path using the character encoding enc, and return an error on 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 of an index (such as I ).
-(Unichar) characterAtIndex :( NSUInteger) index;



Return from (?) Substring from start to end

-(NSString *) substringFromIndex :( NSUInteger) from;



Returns the position starting from the string (?) Substring
-(NSString *) substringToIndex :( NSUInteger);



Returns a substring based on a specified range.
-(NSString *) substringWithRange :( nsange) range;



Compare two strings (Case Insensitive)

-(NSComparisonResult) caseInsensitiveCompare :( NSString *) string;



Compare 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;



Test whether two strings are equal

-(BOOL) isw.tostring :( NSString *) aString;



Returns the upper-case letters of each word in a string, and the lower-case letters of other words.

-(NSString *) capitalizedString;



Returns a string converted to lowercase.

-(NSString *) lowercaseString;



Returns a string converted to uppercase.

-(NSString *) uppercaseString;



Returns a UTF-8 encoded string.

-(_ Strong const char *) UTF8String;



Returns a string of the double type.

-(Double) doubleValue;



Returns a float string to be converted.

-(Float) floatValue;



Returns a string of the int type.

-(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.