_cmd, IMP in Runtime

Source: Internet
Author: User

IMP

imp-pointer to function that actually executes the body of the function

#if !OBJC_OLD_DISPATCH_PROTOTYPEStypedef void (*IMP)(void /* id, SEL, ... */ ); #elsetypedef id (*IMP)(id, SEL, ...); #endif

As you can see, the first two parameters of this function are the ID (the message recipient, that is, the object), and the SEL (the name of the method)

Method/objc_method

Method-pointers to methods in Objective C

typedef struct objc_method *Method;

which

struct objc_method {    SEL method_name                                          OBJC2_UNAVAILABLE;    char *method_types                                       OBJC2_UNAVAILABLE;    IMP method_imp                                           OBJC2_UNAVAILABLE;}                                                            OBJC2_UNAVAILABLE;

_cmd

A variable of the SEL type, the first two hidden parameters of the Objective C function are self and _cmd

Ivar

Ivar-objective instance variables in C

typedef struct objc_ivar *Ivar;

You can see the memory model of the variable

struct objc_ivar {    char *ivar_name                                          OBJC2_UNAVAILABLE;    char *ivar_type                                          OBJC2_UNAVAILABLE;    int ivar_offset                                          OBJC2_UNAVAILABLE;#ifdef __LP64__ int space OBJC2_UNAVAILABLE;#endif} OBJC2_UNAVAILABLE;

_cmd, IMP in Runtime

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.