O-c related -10-dynamic type checking

Source: Internet
Author: User

10-Dynamic type checking

1. Dynamic binding

1) The invocation of a method in OC is not determined by the compiler, but is determined by the runtime

2) There are no method calls in OC, only messages are received. The message is generally called a selector

2. Dynamic type checking

The ability of an object to acquire a type at run time is called introspection, and if you want to know whether an object has a specified method in your code, you can use:

1) determine type or parent class type

-(BOOL) Iskindofclass: (Class) OBJ

Determines whether an object has an object that is instantiated by a class or its subclasses

2) Only judging the type

-(BOOL) Ismemberofclass: (Class) obj

Determines whether an object is instantiated by a class

3) decide whether to subclass

+ (BOOL) Issubclassofclass: (Class) obj

Determine whether a class is a subclass of a class

4) Determine if you can respond

-(BOOL) Respondstoselector: (SEL) Selector

5) Determine if this method is available

-(BOOL) Instancesrespondtoselector: (SEL) Selector

6) Response method

-(ID) Performselector: (SEL) Selector

7) Respond to methods with parameters

-(ID) Performselector: (SEL) Selectorwithobject: (ID) obj

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

O-c related -10-dynamic type checking

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.