zoukankan      html  css  js  c++  java
  • java 和 objective-c 动态获得类型信息

    详细信息,请参看android官方文档中的class类的介绍 ,和苹果的官方文档Objective-C Runtime Reference

    java中常常听到反射reflection,在java的class类的文档中,这样介绍class类,The in-memory representation of a Java class. This representation serves as the starting point for querying class-related information, a process usually called "reflection". 这里可以看出,所谓的反射,就是querying class-related information,为什么命名为reflection,我想是因为,每个对象都是通过对应的class对象映射而成的,那么通过对象去查询class对象的信息,就应该称作reflection。通过每个对象的class对象,能在程序运行时,获得该对象的类的各种信息,比如构建函数,成员变量,等等。

    比如:

    Constructor [] constructors = Class.forName("java.lang.String").getConstructors();

    oc的运行时需要调用运行时库,例如 const char * class_getName(Class cls);

  • 相关阅读:
    85. Maximal Rectangle
    120. Triangle
    72. Edit Distance
    39. Combination Sum
    44. Wildcard Matching
    138. Copy List with Random Pointer
    91. Decode Ways
    142. Linked List Cycle II
    异或的性质及应用
    64. Minimum Path Sum
  • 原文地址:https://www.cnblogs.com/breezemist/p/3468903.html
Copyright © 2011-2022 走看看