Phper beginners objective-c reading notes (1) Basic syntax: static definitions change the scope of global variables and correspond to local scopes. Extern is similar to global in php. The struct defines a multi-dimensional kv array, which is an enumeration type enum that detects the data range. the two use typede phper to Learn objective-c reading notes (1)
Basic syntax:
When the static definition is applied to a global variable, its scope is changed, corresponding to its local range. Extern is similar to global in php.
The struct defines a multi-dimensional kv array. The enum type of the enumeration type detects the data range. The two types can encapsulate the custom type through typedef.
* Indicates the pointer value. & indicates the address fetch operation. (in php, the pointer value is passed by reference. the meaning is different ). The NSString * foo = [NSString stringWithString: "example"] object is also a pointer. after the pointer is obtained, the operation address can be used.
All variables with * are stored in heap, and the opposite is stored in stack.
Object:
A method in a class is also called a message. generally, a method is called to send a message in oc.
Object method init is used to initialize the function (construct compared to the php construct ). Static methods
Put private methods in the implementation file, before calling the method
@ Sythesize: The setter and getter methods are generated during compilation.
Property features include setter/getter, readwrite/readonly, assign/retain/copy, nonatomic
Non-linear security noatomic does not use thread locks, and the performance is slightly improved. retain indicates pointer copy, copy indicates content copy, and applies to NS objects.
Memory management:
Call with alloc, copy, create, use similar [Foo alloc] init...] and CreateFoo () will increase the reserved count by 1
The autorelease will automatically release the memory after you exit the loop, but it is not immediately released. you need to release it immediately in the [Foo release] format, or create an automatic release pool, release (drain or release) at the tail of the recycle body. the nested release pool is preferentially released at the most internal level.
Init is similar to the php constructor _ construct. dealloc is similar to the destructor _ destruct.
The nil object is allowed to call the method in oc, and the result is not executed. Therefore, after the member variable is released, the pointer is set to nil. Otherwise, the memory address to be pointed to does not exist (dangling pointer)
Objects embedded in the delegate mode may cause memory leakage. in this case, set the delegate variable to a weak reference of the assign type.
The reference type of the property. a strong reference indicates that the pointer is retained in the memory and is not recycled.
When the objects in the nib file are not externally referenced, they may be recycled. Therefore, a strongly referenced IBOutlet is created to connect to the owner object.
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.