------Android Training, Java training, look forward to communicating with you! ----------
1. Strong pointer: By default all pointers are strong pointers, keyword __strong
Weak pointers: __week keyword-decorated pointers
2.ARC: The compiler will automatically insert retain, release, Autorelease, where the code is appropriate
ARC's judgment rule, as long as no strong pointer to the object, the object will be released
3. Determine if it is an arc
View project information; Cannot use retain, release, Autorelease, Retaincount, cannot use [super Dealloc] in Dealloc method
Create objects normally without manually releasing objects
4.ARC the problem that the loop introduces, the solution one end uses a weak pointer with a strong pointer
[Email protected] Parameters
Strong strong pointer
Week weak pointer
6.__week person *p=[[person alloc]init];//unreasonable, the object once created is released, the object is released, ARC set the pointer to nil
7. The use of classification, the method of extending the original class
#import " Student.h " @interface Student (study)-(void) run; @end
#import " Student+study.h " @implementation Student (study)-(void) run{ NSLog (@ "study run" );} @end
The methods used in the classification are the same as the original methods, and if the classification is the same as the method name in the class, the method of calling the classification is preferred.
8. Informal agreements
The so-called informal agreement is the category, that is, the categories of nsobject or its subclasses, are informal agreements
9. Extensions-Special classification
The class name is empty, and you can add instance variables and methods to classes, but the method must be implemented in the. m file of the class itself
Variables and methods are equivalent to private
Definition of 10.block
Int (^myblock) (int,int) =^ (int a,int b) {};
Call Mode:
(Myblock);
You can assign a value to Myblock again.
22.typedef Bolck
typedef int (^myblock) (int,int) =^ (int a,int b) {};
Myblock Myblock1,myblock2;
External variables can be accessed within 23.block
When the block is defined, the block copies the value of the external variable in a const manner and places it in the memory of the block and cannot be modified
Global variables can be modified
External variable plus __block then the block is no longer copied in a const manner, it can be modified inside the block, and in the later code, all of the heap space is used
24.block application scenario, passing code blocks as parameters
or block as the return value
25. Mnemonic Inlineblock
26.protocol is a Java-like excuse, but not all of the methods in the protocol must be implemented
Steps:
Defining protocols
@protocol Agreement name <NSObject>
@end
Adoption Agreement
@interface Person:nsobject < protocol 1, Protocol 2>
@end
Ways to Implement Protocols
When an agreement is adhered to, there is a declaration of all the methods in this agreement.
The agreement may also comply with other agreements
OC cannot inherit multiple classes, but can comply with multiple protocols
Modifiers for 27.protocol methods
Must implement @required
Choose to implement @optional
28.id type after add < protocol name > indicates that only objects that have complied with the protocol are assigned
The class name is appended to the < protocol name > indicates that only the object that follows the protocol's current class is assigned
29. Protocol Proxy Mode
The incoming object, in place of the current class, completes a function called the proxy mode
[Email protected]
Replace import importing protocol with @protocol protocol name in. h file
Import protocols in. m files
Import protocol when re-use in main file
Dark Horse programmer-------Objective-c Basics 4