Objective-c Quick Start-Basics (iii)

Source: Internet
Author: User

1. OC There are several ways to create a string object? For example: How to create a String object: @ "Baby".

There are 3 ways to create a string object in OC:

Example: In the main.m file:

  

Console output:

  

2. How do I get the length of a string in OC?

The length of the string to be obtained in OC is "Length";

Example: In the mian.m file:

  

Console output:

  

3. Judge whether the string starts or ends with the specified string;

Example: In the main.m file:

  

Console output:

  

4. Find the range of a string within another string. As found in the string @ "Love You" at @ "I love you" in the range.

Example: In the main.m file:

  

Console output:

  

5. What is the method for splicing of immutable strings? Which method is used for variable string concatenation?

Example: In the main.m file:

  

Console output:

  

6, such as: nsmutablestring * str1 = @ "Deskmate";

nsmutablestring * str2 = @ "I love You";

Speaking of the following 2 cases of execution, the output str1 the result is God horse? Why is this result?

(1). [Str1 STRINGBYAPPENDINGSTRING:STR2]; (2). [Str1 APPENDINGSTRING:STR2];

(1) The result is: I love you at the same table. Reason: concatenation of strings; (2) Error reason: No visible @interface "nsmutablestring" declares the "appendingstring".

7. How many ways to create an array? Try to create an array in these ways.

Example: In the main.m file:

  

Console output:

    

8, the array can only store data?

Only OC objects can be managed in an array, and the objects it manages may be of different types.

9, how to get an array of the number of elements?

Example: In the main.m file:

  

Console output:

  

10, such as an array of existing arrays of objects, such as to set the label 3, how I access the array of corresponding subscript element (object) according to the subscript.

Example: In the main.m file:

  

Console output:

  

11. How do I create a mutable array? How do I add an array element (object) to the array? How do I iterate over this array? Use code to illustrate.

Example: In the main.m file:

  

Console output:

  

12, how to create an empty array?

Example: In the main.m file:

  

Console output:

  

Email:[email protected]

Objective-c Quick Start-Basics (iii)

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.