Summary of black marathon _ video learning <objective-C> ---- 05 Foundation

Source: Internet
Author: User

---------------------- ASP. NET + unity development,. Net training, and hope to communicate with you! ----------------------

I. foundation framework-struct

1. Basic Knowledge

Foundation-basic framework. The Framework contains many common data types, such as struct, enumeration, and classes, which are the basis of other IOs frameworks.

If you want to use the data type in the foundation framework, you can include its main header file.

That is, # import <Foundation/Foundation. h>

Supplement: Compared with the underlying core foundation framework, almost all the codes in the core foundation framework are in C language, while those in foundation are in OC.

 

2. Introduction and simple use of common struct

Common struct:

 

1> basic use of nsang

 

Create variable

 

2> nspoint/cgpoint usage

 

3> Use of nssize/cgsize

 

4> Use of nsrect/cgrect

 

General Usage:

In development, how should I print the attribute values in the struct to be verified?

 

Use the framework function to convert the corresponding struct into a string, and then print the string directly.

 

5> some frequently used struct functions in the foundation framework

Ii. foundation framework-string

1. Some common classes in the foundation framework

String type:

Nsstring: unchangeable string

Nsmutablestring: Variable string

Set Type:

1>

Nsarray: OC immutable Array

Nsmutablearray: variable array

2>

Nsset:

Nsmutableset:

3>

Nsdictiorary

Nsmutabledictiorary

Others:

Nsdate

Nsobject

2. Use and note of nsstring and nsmutablestring

1> six string creation forms

 

2> usage notes

(1) Import and Export of strings

 

(2) class methods

 

3> Use and note of nsmutablestring

 

Iii. foundation framework-Set

1. nsarray and nsmutablearray

1> nsarray immutable Array

(1) Basic Introduction to nsarray

Nsarray is an array used in OC. It is object-oriented and manipulated in the form of object-oriented. It is an immutable array.

The disadvantage of a C-language array is that the array can only store elements of the same data type.

The OC array can only store OC objects, but cannot store non-OC objects, such as int, struct, and enumeration.

(2) create nsarray

 

(3) access to nsarray

(4) nsarray Traversal

Arrays can be traversed in the following ways:

First create an array

 

Method 1: Use for loop Traversal

 

In-depth research on block traversal:

Each time an element is obtained, it is passed to OBJ, and a block is called, and the current element and index location are passed to the block as parameters.

Note 1: Break is only used in two scenarios: Switch and loop structure.

Note 2: The stop parameter is used to stop traversal. If its value is yes, it is stopped.

2> nsmutablearray variable array

(1) Basic use of nsmutablearray

Note: nsmutablearray inherits from nsarray and has almost all nsarray methods.

 

2. nsset and nsmutableset

1> nsset immutable set

Basic usage:

 

2> nsmutableset variable set

Basic usage:

 

3> comparison between nsset and nsarray

(1) Commonalities:

1) All are collections and can store multiple objects.

2) Only OC objects can be stored, and non-OC object types (such as int and other basic data types and struct, enumeration, etc.) cannot be stored ).

3) They are both immutable and each has a mutable subclass.

(2) differences:

1) nsarray has sequence, and nsset has no sequence.

3. nsdictionary and nsmutabledictionary

1> nsdictionary unchangeable dictionary

(1) Introduction

Dictionary in reality: Find the specific content based on the index

Nsdictionary in OC: locate the value based on the key. All the things stored in the bucket are key-value pairs.

(2) create nsdictionary

 

Note: Quick dictionary creation is a compiler feature.

(3) access to nsdictionary

 

(4) nsdictionary Traversal

 

2> nsmutabledictionary variable dictionary

(1) Basic use of nsmutabledictionary

 

(2) nsmutabledictionary usage instructions

 

Note: This quick creation method only applies to immutable dictionaries.

 

 

---------------------- ASP. NET + unity development,. Net training, and hope to communicate with you! ----------------------

For details, see www.itheima.com.

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.