Objective-c (NSString, BOOL, multi-file development)

Source: Internet
Author: User

NSString

Represents a string class in OC

%@ is the format character for objects in OC

printf cannot print objects in OC

By stringWithFormat: This class method, print the formatted string

Cases

int a = 10;

NSString * str = [NSString stringwithformat:@ "height is%i", a];

NSLog (@ "%@", str);

Calculates the length of a string by the method of seeking length in the nssting

The method of seeking length in OC, when printing, is in the character units of each country. A space is also a character

Example unsigned long OcL = [str length]; Length count character lengths

BOOL

The return value of type bool, the method name is usually preceded by the IS

The bool return value Yes,no either Yes 1, otherwise NO is 0.

OC Multi-File development

implement code with multiple files to increase readability and improve programming efficiency

Define a class divided into 2 files:. h files,. m files

. h file: A declaration of a member variable, method

. m file: implementation of a method

To use a class, you need the. h file for the #import class.

Objective-c (NSString, BOOL, multi-file development)

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.