Objective-C type

Source: Internet
Author: User

1. Strings

1) simple string

 
Nsstring * astring =@"This is a string"; Nsstring* Anotherstring =@"And this is another one";

2) object initialization

 
Nsstring * astring = [[nsstring alloc] initwithstring:@"Some string literal"]; Nsstring* Astring = [nsstring stringwithstring:@"Some string literal"];

3) format the string

IntThevalueofpi =3;//Produces the string "Pi is exactly 3! "Nsstring * astring = [nsstring stringwithformat:@"Pi is exactly % d!", Thevalueofpi];

4) object formatting

Nsstring * astring =@"Criminals"; Nsstring* Anotherstring = [nsstring stringwithformat:@"When you % @ strings, only % @ willuse strings.",@"Criminalize", Astring];

5) string comparison

Nsstring * astring =@"Hello"; Nsstring* Anotherstring =@"Hello"; Bool stringsareequal= ([Astring is1_tostring: anotherstring]);

Bool stringsareequal = (astring = anotherstring); // This is incorrect.

 

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.