Read effective Objective c Summary (iii)

Source: Internet
Author: User

  1. The same element is not allowed in the collection collection class, as in Nsset, but if it is written like this: 650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M01/71/F3/ Wkiom1xbh7od61diaaexnbskyzu907.jpg "title=" 1.jpg "alt=" Wkiom1xbh7od61diaaexnbskyzu907.jpg "/>

    This will result in the output of the first set being two identical elements, and the output of the second set has only one element

  2. Class Family mode: Because there is no abstract base class in OC, use Factory mode, for example we can create UIButton similar method: 650) this.width=650; "Src=" HTTP://S3.51CTO.COM/WYFS02/M01/72/14 /wkiom1xdf7jhmqazaakbfcemzii099.jpg "title=" 4.png "alt=" Wkiom1xdf7jhmqazaakbfcemzii099.jpg "/> To determine whether the class to which an instance belongs is in the class family, use Iskindofclass to not use Ismemeberofclass, because some classes have internal types

  3. The use of associated objects is actually creating a channel in the local space to share certain classes, such as sharing blocks in Uialert

  4. The message is composed of the object that accepts the message and the function pointer, and if the runtime is not used, the compiler generates the function code that is hardcoded, if dynamic binding is used:

    First, use the @dynamic keyword to decorate the properties that need to be dynamically generated, and then override the Resolveinstancemethod method of the class

    Second, if the first step still does not find a suitable method, it will call the Forwardingtargetforselector method forward to the other object, always execute to NSObject

    Thirdly, if the second step is not successful, it is necessary to start the complete message forwarding mechanism, first create the Nsinvocation object, and encapsulate the message information that has not been processed in this object.

  5. You can change the pointer of IMP in the list of functions in objc_msgsend by means of the method exchange.

  6. OC objects are actually constructed using structs and pointers, using Ismemberofclass to determine if they are instances of a particular class, using Iskindofclass to determine whether they are instances of their classes or derived classes, rather than using [A class] = = [B class]


Read effective Objective c Summary (iii)

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.