1. You do not need to write three keywords: retain, release, and autorelease;
2. An object will not be destroyed as long as it is pointed by the strong pointer until all the strong pointers pointing to it point to other places;
3. By default, all instance variables and local variables are of the strong type;
4. The weak type pointer does not hold the object. When the indicated object loses all the strong pointers pointing to it, the object is destroyed and the weak pointer automatically points to nil;
6. Remember:-fobjc-arc and-fno-objc-arc;
7. In addition to basic types such as int, float, and bool, most assigns can be replaced by weak;
8. Existing
Instance variable for _ weak property must be _ weak solution: @ Property indicates that weak should be declared as _ weak in the attribute list;
9,
OSStatus status = SecItemCopyMatching((CFDictionaryRef) attributeQuery, (CFTypeRef *) &attributeResult);
The changes are as follows:
CFTypeRef attri = (__bridge CFTypeRef)attributeResult; OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)attributeQuery, &attri);
10. dealloc only handles some necessary tasks, such as suspending an unfinished network request, deleting a registered proxy or notification. Release and [Super dealloc] are not required.
11. Use the @ autoreleasepool {} block to replace the NSAID utoreleasepool;
12. The attribute name is not developed in new mode;
13. nsallocateobject and nsdeallocateobject are not used
14,
_ Bridge
Simple assignment does not affect the retain count of objects on both sides.
_ Bridge_transfer
Release objects on the right after assigning values
_ Bridge_retained
The objects on the right are retained after the assignment.
15. iboutlet should be weak-type;
16. To call the core foundation function named create, copy, and retain, you must use cfbridgingrelease () to safely pass the value to arc;
17. To avoid self capture, the following code mode is recommended:
__weak id weakSelf = self; block = ^() { id strongSelf = weakSelf; if (strongSelf != nil) { // do stuff with strongSelf } }
18. Arc Singleton
+ (id)sharedInstance { static ClassName *sharedInstance; static dispatch_once_t done; dispatch_once(&done, ^{ sharedInstance = [[ClassName alloc] init]; }); return sharedInstance; }