Write high-quality iOS code--effective objective-c 2.0 Reading notes

Source: Internet
Author: User
Tags gcd

Write high-quality iOS code--effective objective-c 2.0 Reading notes

This book was finished at the beginning of the year, feeling good, introduced a lot of small points, are not very concerned about the weekdays.

The 1th chapter is familiar with Objective-c

This chapter is nothing to introduce.

1th: Understand the origin of the Objective-c language 2nd: Minimize the introduction of other header files in the header file of the class 3rd: Use more literal syntax, less the equivalent of the method 4th: Multi-use type constants, less use # define preprocessing directives

Understand why you should use less than # define preprocessing directives. And then decide for yourself which one to use.

5th: Using enumerations to represent States, options, status Codes, 2nd object, message, run-time 6th: Understanding the concept of "attribute"

Properties: Variables + methods + attribute traits

7th: Try to access instance variables directly inside the object

Some optimizations for performance

8th: Understanding the concept of "object equivalence" 9th: Implementing details in "class family mode" hiding

Factory mode

10th: Use associative objects to store custom data in existing classes

Category Riga Properties

11th: Understanding the role of objc_msgsend

Passing messages

12th: Understanding the message forwarding mechanism

Dynamic method parsing: Sending Resolveinstancemethod to the current class: Checks whether a method has been added to the class dynamically

Fast message forwarding: Check that the class implements the Forwardingtargetforselector: Call this method if it is implemented. If the method returns a value object that is non-nil or non-self, resend the message to the returned object.

Standard message forwarding: Runtime sends Methodsignatureforselector:, Message gets selector corresponding method signature. The return value is non-null by forwardinvocation: Forwards the message, and the return value is null to send Doesnotrecognizeselector to the current object: program crashes exiting

13th: "Method Deployment Technology" debugging "black Box Method"

is the method swizzling. Abuse is not recommended.

14th: Understanding the purpose of "class object"

Actually, it's c-oop.

3rd Chapter interface and API design 15th: Avoid namespace conflicts with prefixes 16th: provide "All-in-one initialization method" 17th: Implement Description Method 18th bar: Use immutable objects as much as possible

It's really going to be a problem if you don't notice.

19th: Use a clear and coordinated naming method 20th: Prefix the private method name

Write more to know a lot of not to do, sooner or later will encounter problems, did not meet is to write too little.

21st: Understanding the OBJECTIVE-C Error Model 22nd: Understanding the Nscopying Agreement 4th chapter of the Agreement and classification 23rd: Inter-object communication through delegation and data source protocol 24th: Spread the implementation code of the class to a manageable number of categories 25th: Always # # # Class name plus prefix for third-party classes 26th: Do not declare attribute 27th in classification: use "Class-continuation classification" to hide implementation Details 28th article: Providing anonymous objects through a protocol

Ducks are like ducks.

5th Chapter Memory Management 29th: Understanding reference count

One of three basic ways to manage memory

30th: Simplifying reference counting with arc

Using ARC to make programming more concise

31st: Only release the reference in the Dealloc method and dismiss the listener 32nd: note the memory management issues when writing the "Exception Security Code" 33rd: avoid retaining ring 34th with weak references: Reduce memory peaks with "auto-free pool block" 35th: with "Zombie Object" Debug memory management issues 36th: Do not use Retaincount 6th block and the Great Center to distribute 37th: understand the concept of "block"

Closure (in a function object, the structure of a local variable that is enclosed in the environment) in the specific implementation of OC

38th: Create typedef 39th for common block types: Reduce code dispersion with handler block 40th: Do not appear when you use a block to refer to the object to which it belongs
#define DEF_WEAKSELF                        __weak __typeof(self) weakSelf = self;#define DEF_STRONGSELF                      __strong __typeof(weakSelf) self = weakSelf;
41st: Multi-use distribution queue, less use of synchronization lock 42nd: Multi-use GCD, less use of Performselector series 43rd: Grasp the GCD and operation of the queue of the use of time 44th: through the dispatch group mechanism, Perform the task according to the system resource condition 45th: Use Dispatch_once to perform a thread-safe code that runs only one time 46th: do not use Dispatch_get_current_queue

Beware of deadlocks.

7th Chapter System Framework 47th: familiar with the system framework 48th: Multi-use block enumeration, Less use for loop 49th: Use seamless bridging 50th for customizing the collection of its memory management semantics: Nscache instead of Nsdictionary 51st: streamlining initialize and load implementation code 52nd: Don't forget Nstimer will keep its target. Object

Write high-quality iOS code--effective objective-c 2.0 Reading notes

Related Article

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.