Numerical object of basic object of foundation frame in OC

Source: Internet
Author: User

The OBJECTIVE-C programming is mainly used in two framework foundation and Applicationkit. The foundation framework mainly defines some basic classes. All classes in the foundation framework inherit from the NSObject object.

The number types mentioned in the foundation framework can be encapsulated into an object by the NS number type and then manipulated by the corresponding object.

1. Introduction to Digital objects

2. Creation and initialization of numeric objects

2.1 Initialized with the Numberwith base data type (the base data type is capitalized in the first letter).

Format: Digital object =[nsnumber creation and initialization method * * *];

2.2 initialized with the Initwith base data type.

Format: Numeric object name ==[[nsnumberalloc] Initialization method initialization value];

3. Value of a numeric object

Format: [Object name base data type value];

The string type mentioned in the 4.Foundation framework can be encapsulated into an object by an NS string type, and then manipulated on the object. Strings can be divided into modifiable (nsstring) and non-modifiable (nsmutablestring);

4.1. Non-modifiable strings in OC

Format: NSString * Identifier [email protected] "string to be assigned";

String Common functions:

Stringwithstring create another string with one string

Format: stringwithstring: (nsstring*) string

stringWithFormat Direct assignment of a string

Format: stringwithformat:nsstring

Stringbyappendingstring adds a string to the back of a string

Format: stringbyappendingstring:nsstring

Isequaltostring Comparison of two strings

Format: isequaltostring:nsstring

Hasprefix:nsstring is used to judge a string prefix (such as a domain name, website).

Hassuffix:nsstring is used to determine string suffixes (such as finding files in MP3, video, and so on).

The return value type of the above two functions is type bool, and the returned result is yes or no;

Uppercasestring Convert lowercase letters to uppercase

Format: String variable 2=[string variable name 1 uppercasestring];

LowerCaseString converts uppercase letters in a string to lowercase letters

Format: String variable name 2=[string variable name 1lowercaseString].

Substringtoindex A string that is used to intercept n characters

Format: String variable 2=[string variable 1 substringtoindex:n];

4.2NSString strings cannot be modified. Use nsmutablestring if you need to insert, delete, or otherwise manipulate a string object. It can be said that Nsmutablestring is a subclass of NSString, so Nsmutablestring inherits all the class methods and object methods of NSString.

Numerical object of basic object of foundation frame in OC

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.