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 .