iOS Basics-Small Knowledge point collection (1)

Source: Internet
Author: User

do not accumulate Kuibu , not even thousands of miles ; does not accumulate the small stream , nothing to form Jianghai . ----Xunzi

Collect a little bit of knowledge in learning iOS and make a little progress every day.

(i)@class and #import

Class: Declare only classes, do not introduce class files, speed up compilation, prevent class import errors, and still need to import the entire class file in M.

Import imports the entire class file, which needs to be used when you need to use variables, functions, and protocols in the class.


(ii) static variable statics, global variable extern, local variables, instance variables

Static: Used for an entire class rather than a single object, hidden in a class, invisible to the outside.

Advantages of static variables:1, save memory. Static variables are stored only one place, but are used by all objects. 2, its value can be updated. 3, can improve time efficiency. Whenever an object updates a static variable once, all objects have access to the updated value.

extern: A variable defined outside a method, scoped to the entire source program. Global variables cannot be defined in more than one m file.

Local variables: Variables defined in a method, scope is within a method.

Instance variables: Defined outside of the class file method


(iii) Nsarray and Nsmutablearray

first, Nsarray can store only objective-c objects, not basic data types in the C language. such as: int,flot, pointers and so on. When using Nsarray, It is important to note that you must end with nil to represent the end.

Nsarray creates a static array, and once created, it is no longer possible to add and delete objects in the array, only to replace .

Nsmutalbearray creates a dynamic array, optionally adding or removing elements from the array.


(iv) The difference between bool, BOOL and Boolean

In the objc.h file, define the following

<span style= "FONT-FAMILY:SIMSUN;FONT-SIZE:18PX;" >typedef signed Char     BOOL;//bool is explicitly signed so @encode (BOOL) = = "C" rather than "C"//Even If-funsign Ed-char is used. #define Objc_bool_defined#define YES             (bool) 1#define NO              (BOOL) 0</span>

BOOL is a signed char type,Boolean is a unsigned char type, andbool is an integral type. BOOL is used in the OC framework, and most of the rest is in bool. BOOL is commonly used in OC programming .


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.