Runtime 源码解析

2019-08-03 07:35栏目:ca888圈内

===================各项参数============

其中yes/no也可使用1/0;pixel value为具体的数值,单位象素。

4.5.2 移动代码

点击张开树形菜单“系统代码”,选取二个代码后点击“移动”按键,如下图4.5.2-第11中学所示,选用必要活动到的对象代码组,点击确认,就能够完毕代码的调动。这段时间平台上只帮忙代码移动,代码组临时不支持活动。

 ca888会员登录 1

图4.5.2-1  移动代码

#region LoadCodeTypes
        private void LoadCodeTypes(TreeNode currentNode, DMESYS_SYSCODE_TYPE currentCodeType)
        {
            List<DMESYS_SYSCODE_TYPE> subCodeTypes = null;
            if (currentCodeType != null)
                subCodeTypes = DBOSYS_SYSCODE_TYPE.GetSubCodeTypes(currentCodeType);
            else
                subCodeTypes = DBOSYS_SYSCODE_TYPE.GetSYS_SYSCODE_TYPEEntities();

            foreach (DMESYS_SYSCODE_TYPE rt in subCodeTypes)
            {
                TreeNode node = currentNode.ChildNodes.Add();
                node.Tag = rt;
                node.Text = rt.Name;
                node.CollapsedImageIndex = 1;
                node.ExpandedImageIndex = 2;

                LoadCodeTypes(node, rt);
            }
        }
        #endregion

        private bool MoveCode()
        {
            if (destObj == null)
            {
                lbTip.Visible = true;
                return false;
            }

            if (destObj is DMESYS_SYSCODE_TYPE)
            {
                target.Syscode_Type_Id = (destObj as DMESYS_SYSCODE_TYPE).Id;
                DBOSYS_SYSCODE.UpdateDMESYS_SYSCODE(target);
                return true;
            }

            return false;
        }

 

 

代码 sculptingtable

protocol_getMethodDescription

/** 
 * Returns a method description structure for a specified method of a given protocol.
 * 
 * @param p A protocol.
 * @param aSel A selector.
 * @param isRequiredMethod A Boolean value that indicates whether aSel is a required method.
 * @param isInstanceMethod A Boolean value that indicates whether aSel is an instance method.
 * 
 * @return An c objc_method_description structure that describes the method specified by e aSel,
 *  e isRequiredMethod, and e isInstanceMethod for the protocol e p.
 *  If the protocol does not contain the specified method, returns an c objc_method_description structure
 *  with the value c {NULL, c NULL}.
 * 
 * @note This function recursively searches any protocols that this protocol conforms to.
 */
 // 返回协议中指定方法的描述
OBJC_EXPORT struct objc_method_description
protocol_getMethodDescription(Protocol * _Nonnull proto, SEL _Nonnull aSel,
                              BOOL isRequiredMethod, BOOL isInstanceMethod)
    OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);

代码:

struct objc_method_description desc = protocol_getMethodDescription(protocolA, @selector(numberOfSectionsInTableView:), NO, YES);

打印:

(lldb) po desc.name
"numberOfSectionsInTableView:"

(lldb) po desc.types
"q24@0:8@16"

复制代码 代码如下:

4.5 代码(字典)管理

系统代码是阳台置于的、通用的、统一的多少描述。

代码管理(数据字典)是成套阳台中数据描述的可行机制。通过分界面实行可视化的操作和维护,能高效录入和修改平台上联合的字典数据。有效抓好了数量的再次利用率和制品、项指标开支效能。整个数据字典数据为框架平台所分享,用户能够越来越好地对系统举行自定义管理,以满意本人的天性化需要。

代码管理的意义作业区(用户操作)分界面如下图4.5-1所示,通过首要的操作开关和新闻内容可见其作用有:

① 新添代码组、代码,编辑代码组、代码,
② 删除代码组、代码,移动代码,
③ 代码组、代码的头一无二标志,排序作用和备注音信等。

里头作用操作按钮的事态会基于选用的右边树型中分裂节点和不相同登入用户的动作权限而改造。

平台在最近仅匡助二级深度的树型代码结构,可依据实际要求实行增加、修改、删除或位移等对平台代码进行归类和调动。

ca888会员登录 2 

图4.5-1  代码处理分界面

#region LoadCodeTypes, LoadCodes
        private void LoadCodeTypes(TreeNode currentNode, DMESYS_SYSCODE_TYPE currentCodeType)
        {
            List<DMESYS_SYSCODE_TYPE> subCodeTypes = null;
            if (currentCodeType != null)
                subCodeTypes = DBOSYS_SYSCODE_TYPE.GetSubCodeTypes(currentCodeType);
            else
                subCodeTypes = DBOSYS_SYSCODE_TYPE.GetSYS_SYSCODE_TYPEEntities();

            foreach (DMESYS_SYSCODE_TYPE rt in subCodeTypes)
            {
                TreeNode node = currentNode.ChildNodes.Add();
                node.Tag = rt;
                node.Text = rt.Name;
                node.CollapsedImageIndex = 1;
                node.ExpandedImageIndex = 2;

                LoadCodeTypes(node, rt);
            }
        }

        private void LoadCodes()
        {
            codes.Clear();
            codes = DBOSYS_SYSCODE.GetSYS_SYSCODEEntities();

            foreach (DMESYS_SYSCODE r in codes)
            {
                TreeNode tn = CallFindNode(r.Syscode_Type_Id, tvCodes);
                if (tn != null)
                {
                    TreeNode node = tn.ChildNodes.Add();
                    node.Tag = r;
                    node.Text = r.Name;
                    node.CollapsedImageIndex = 3;
                    node.ExpandedImageIndex = 3;
                }
            }
        }

        private TreeNode FindTreeNode(string codeTypeId, TreeNode tnParent)
        {
            if (tnParent == null || tnParent.Tag is DMESYS_SYSCODE)
                return null;
            if ((tnParent.Tag as DMESYS_SYSCODE_TYPE).Id == codeTypeId)
                return tnParent;
            TreeNode tnRet = null;
            foreach (TreeNode tn in tnParent.ChildNodes)
            {
                tnRet = FindTreeNode(codeTypeId, tn);
                if (tnRet != null)
                    break;
            }
            return tnRet;
        }

        private TreeNode CallFindNode(string codeTypeId, TreeControl treeView)
        {
            TreeNodeCollection nodes = treeView.RootNodes[0].ChildNodes;
            foreach (TreeNode n in nodes)
            {
                TreeNode temp = FindTreeNode(codeTypeId, n);
                if (temp != null)
                    return temp;
            }
            return null;
        }
        #endregion

 

代码 bundlewrap

protocol_addProperty

/** 
 * Adds a property to a protocol. The protocol must be under construction. 
 * 
 * @param proto The protocol to add a property to.
 * @param name The name of the property.
 * @param attributes An array of property attributes.
 * @param attributeCount The number of attributes in e attributes.
 * @param isRequiredProperty YES if the property (accessor methods) is not optional. 
 * @param isInstanceProperty YES if the property (accessor methods) are instance methods. 
 *  This is the only case allowed fo a property, as a result, setting this to NO will 
 *  not add the property to the protocol at all. 
 */
 //
OBJC_EXPORT void
protocol_addProperty(Protocol * _Nonnull proto, const char * _Nonnull name,
                     const objc_property_attribute_t * _Nullable attributes,
                     unsigned int attributeCount,
                     BOOL isRequiredProperty, BOOL isInstanceProperty)
    OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0, 2.0);

代码:

    // 创建新的协议
    Protocol *newProtocol = objc_allocateProtocol("DataDelegate");

    // 给一个协议添加一个属性
    objc_property_attribute_t attr_T = {"T", "@"NSString""};   // @encod
    objc_property_attribute_t attr_N = {"N", ""};  // 原子性
    objc_property_attribute_t attr_C = {"C", ""};  // copy
    objc_property_attribute_t attr_V = {"V", "_age"}; // 实例变量
    objc_property_attribute_t attrs[] = {attr_T, attr_N, attr_C, attr_V};
    protocol_addProperty(newProtocol, "age", attrs, 4, YES, YES);

    // 打印协议的属性
    unsigned int outCount;
    objc_property_t *propertyList = protocol_copyPropertyList(newProtocol, &outCount);
    for (unsigned int i = 0; i < outCount; i  ) {
        objc_property_t property = propertyList[I];
        unsigned propertyCount;
        objc_property_attribute_t *attrList = property_copyAttributeList(property, &propertyCount);
        for (unsigned int j  = 0; j < propertyCount; j  ) {
            objc_property_attribute_t attr = attrList[j];
            const char *name = attr.name;
            const char *value = attr.value;
            NSLog(@"name: %s, value: %s", name, value);
        }
    }

打印:

TestProject[33846:1268389] name: T, value: @"NSString"
TestProject[33846:1268389] name: N, value: 
TestProject[33846:1268389] name: C, value: 
TestProject[33846:1268389] name: V, value: _age

<a href="#" onclick="javascript:window.open(', resizable=no,location=no, status=no')">aaaaaaaaaaaaaaa</a>

4.5.1 新扩大、编辑和删除

增加产量代码组和代码:点击张开树形菜单“系统代码”,能够看来平台置于的一部分代码组和代码。选用“系统代码”后点击“新扩展分类”开关,能够加多代码组;选取已有的代码组,点击“新添代码”开关,可以加上具体的代码。

在增加产量代码组或代码的进程中,个中带铜锈绿星号标识“*”的条约,标记、名称和排序ID是必供给填写的内容。平台会检查实验该代码组或代码的标记、名称在凉台上的合法性,确定保障代码组或代码的标志、名称的独一性和可用性。

切切实实加多代码组、代码的操作分界面如下图4.5.1-1所示:

 ca888会员登录 3

 ca888会员登录 4

图4.5.1-1  新添代码组、代码

private void InfoUpdatedADD()
        {
            if (dmeObj == null)
            {
                lbInfo.Text = "在“系统代码”下新增如下代码分类";
                return;
            }

            if (dmeObj != null && dmeObj is DMESYS_SYSCODE_TYPE)
            {
                dmeCodeType = dmeObj as DMESYS_SYSCODE_TYPE;
                lbInfo.Text = "在代码分类“"   dmeCodeType.Name   "”下新增如下代码";
                return;
            }
        }

        private bool InfoUpdatedEDIT()
        {
            if (dmeObj == null)
            {
                lbInfo.Text = "加载代码类型信息时出错!";
                lbInfo.ForeColor = Color.Red;
                ucCodes.IsEnabled(false);
                return false;
            }

            if (dmeObj != null && dmeObj is DMESYS_SYSCODE_TYPE)
            {
                dmeCodeType = dmeObj as DMESYS_SYSCODE_TYPE;
                lbInfo.Text = "编辑代码分类“"   dmeCodeType.Name   "”";
                return true;
            }

            if (dmeObj != null && dmeObj is DMESYS_SYSCODE)
            {
                dmeCode = dmeObj as DMESYS_SYSCODE;
                lbInfo.Text = "编辑代码“"   dmeCode.Name   "”";
                return true;
            }

            return false;
        }

        private bool InsertorUpdateCodes()
        {
            if (dmeCode == null)
            {
                dmeCode = new DMESYS_SYSCODE();
            }

            if (dmeCodeType == null)
            {
                dmeCodeType = new DMESYS_SYSCODE_TYPE();
            }

            if (action == Action.ADD)
            {
                if (dmeObj == null && DoValidatedCodes())
                {
                    dmeCodeType.Id = FeiQing.DBO.DBOService.GetID();
                    DBOSYS_SYSCODE_TYPE.InsertDMESYS_SYSCODE_TYPE(dmeCodeType);
                    return true;
                }
                if (dmeObj is DMESYS_SYSCODE_TYPE && DoValidatedCodes())
                {
                    dmeCode.Syscode_Type_Id = dmeCodeType.Id;
                    dmeCode.Id = FeiQing.DBO.DBOService.GetID();
                    DBOSYS_SYSCODE.InsertDMESYS_SYSCODE(dmeCode);
                    return true;
                }
                return false;
            }

            if (action == Action.EDIT)
            {
                if (dmeObj is DMESYS_SYSCODE_TYPE && DoValidatedCodes())
                {
                    dmeCodeType.Id = (dmeObj as DMESYS_SYSCODE_TYPE).Id;
                    DBOSYS_SYSCODE_TYPE.UpdateDMESYS_SYSCODE_TYPE(dmeCodeType);
                    return true;
                }
                if (dmeObj is DMESYS_SYSCODE && DoValidatedCodes())
                {
                    dmeCode.Id = (dmeCode as DMESYS_SYSCODE).Id;
                    DBOSYS_SYSCODE.UpdateDMESYS_SYSCODE(dmeCode);
                    return true;
                }
                return false;
            }

            return false;
        }

        private bool DoValidatedCodes()
        {
            if (String.IsNullOrEmpty(ucCodes.LbTxtTag))
            {
                lbTip.Text = "“标识”不能为空。";
                lbTip.ForeColor = Color.Red;
                return false;
            }
            if (String.IsNullOrEmpty(ucCodes.LbTxtName))
            {
                lbTip.Text = "“名称”不能为空。";
                lbTip.ForeColor = Color.Red;
                return false;
            }
            if (String.IsNullOrEmpty(ucCodes.LbTxtOrder))
            {
                lbTip.Text = "“排序ID”不能为空。";
                lbTip.ForeColor = Color.Red;
                return false;
            }
            if (!FeiQing.Util.DataValidator2.IsNumber(ucCodes.LbTxtOrder))
            {
                lbTip.Text = "“排序ID”必须为数值。";
                lbTip.ForeColor = Color.Red;
                return false;
            }

            if (dmeObj == null && dmeCodeType != null && action == Action.ADD)
            {
                dmeCodeType.Tag = ucCodes.LbTxtTag;
                dmeCodeType.Name = ucCodes.LbTxtName;
                dmeCodeType.Order_Id = Int32.Parse(ucCodes.LbTxtOrder);
                dmeCodeType.Remark = ucCodes.LbTxtRemark;
            }
            if (dmeObj is DMESYS_SYSCODE_TYPE && dmeCode != null && action == Action.ADD)
            {
                dmeCode.Tag = ucCodes.LbTxtTag;
                dmeCode.Name = ucCodes.LbTxtName;
                dmeCode.Order_Id = Int32.Parse(ucCodes.LbTxtOrder);
                dmeCode.Remark = ucCodes.LbTxtRemark;
            }
            if (dmeObj is DMESYS_SYSCODE_TYPE && dmeCodeType != null && action == Action.EDIT)
            {
                dmeCodeType.Tag = ucCodes.LbTxtTag;
                dmeCodeType.Name = ucCodes.LbTxtName;
                dmeCodeType.Order_Id = Int32.Parse(ucCodes.LbTxtOrder);
                dmeCodeType.Remark = ucCodes.LbTxtRemark;
            }
            if (dmeObj is DMESYS_SYSCODE && dmeCode != null && action == Action.EDIT)
            {
                dmeCode.Tag = ucCodes.LbTxtTag;
                dmeCode.Name = ucCodes.LbTxtName;
                dmeCode.Order_Id = Int32.Parse(ucCodes.LbTxtOrder);
                dmeCode.Remark = ucCodes.LbTxtRemark;
            }

            return true;
        }

 

编写代码组和代码:首如若在代码组或代码的标志,名称,排序,备注等音讯发出转移的境况时展开的编辑撰写操作。点击展开树形菜单“系统代码”,在树型目录下抉择三个代码组大概代码后点击“编辑”开关,即完毕对应代码组或代码音讯的退换。具体编辑代码组、代码的操作分界面如下图4.5.1-第22中学所示:

 ca888会员登录 5

图4.5.1-2  编辑代码组、代码

 

剔除代码组和代码:点击张开树形菜单“系统代码”,在树型目录下抉择三个代码组或代码后点击“删除”按键,图4.5.1-3显得了去除操作的提示对话框分界面。

备考:对于具备代码的代码组是无力回天直接删除的,首先须要删除其下属的代码。

 ca888会员登录 6

 ca888会员登录 7

图4.5.1-3  删除代码组或代码提醒

 

private void btnDelete_Click(object sender, System.EventArgs e)
        {
            if (IsCodeType())
            {
                if (selectedNode.ChildNodes.Count > 0)
                {
                    GUIHelper.MessageToUserInfo("提示:该代码分类包含代码,无法直接删除!");
                    return;
                }
                if (GUIHelper.MessageQuestion("确定要删除代码分类“"   (selectedObj as DMESYS_SYSCODE_TYPE).Name   "”吗?", "删除代码分类"))
                {
                    DBOSYS_SYSCODE_TYPE.DeleteDMESYS_SYSCODE_TYPE(selectedObj as DMESYS_SYSCODE_TYPE);
                    btnRefresh_Click(sender, e);
                    return;
                }
            }
            if (IsCode())
            {
                if (GUIHelper.MessageQuestion("确定要删除代码“"   (selectedObj as DMESYS_SYSCODE).Name   "”吗?", "删除代码"))
                {
                    DBOSYS_SYSCODE.DeleteDMESYS_SYSCODE(selectedObj as DMESYS_SYSCODE);
                    btnRefresh_Click(sender, e);
                    return;
                }
            }
        }

 

代码 mushroomsprout

结构
struct objc_method {
    // 方法名字
    SEL _Nonnull method_name                                 OBJC2_UNAVAILABLE;
    // 方法类型
    char * _Nullable method_types                            OBJC2_UNAVAILABLE;
   // 方法指针
    IMP _Nonnull method_imp                                  OBJC2_UNAVAILABLE;
} 
参数
取值范围
说明
alwaysLowered
yes/no
指定窗口隐藏在所有窗口之后
alwaysRaised
yes/no
指定窗口悬浮在所有窗口之上
depended
yes/no
是否和父窗口同时关闭
directories
yes/no
Nav2和3的目录栏是否可见
height
pixel value
窗口高度
hotkeys
yes/no
在没菜单栏的窗口中设安全退出热键
innerHeight
pixel value
窗口中文档的像素高度
innerWidth
pixel value
窗口中文档的像素宽度
location
yes/no
位置栏是否可见
menubar
yes/no
菜单栏是否可见
outerHeight
pixel value
设定窗口(包括装饰边框)的像素高度
outerWidth
pixel value
设定窗口(包括装饰边框)的像素宽度
resizable
yes/no
窗口大小是否可调整
screenX
pixel value
窗口距屏幕左边界的像素长度
screenY
pixel value
窗口距屏幕上边界的像素长度
scrollbars
yes/no
窗口是否可有滚动栏
titlebar
yes/no
窗口题目栏是否可见
toolbar
yes/no
窗口工具栏是否可见
Width
pixel value
窗口的像素宽度
z-look
yes/no
窗口被激活后是否浮在其它窗口之上

饥馑联机版新本子代码大全;饔飧不给联机版新本子出来以往,更新了大气的古生物和物品,上边我为大家整理了那几个新东西的代码,游戏用户们在调整台打入相应的代码就能够取得那些东西了。

object_getInstanceVariable
/** 
 * Obtains the value of an instance variable of a class instance.
 * 
 * @param obj A pointer to an instance of a class. Pass the object containing
 *  the instance variable whose value you wish to obtain.
 * @param name A C string. Pass the name of the instance variable whose value you wish to obtain.
 * @param outValue On return, contains a pointer to the value of the instance variable.
 * 
 * @return A pointer to the c Ivar data structure that defines the type and name of
 *  the instance variable specified by e name.
 */
// 获取实例的实例变量的值
OBJC_EXPORT Ivar _Nullable
object_getInstanceVariable(id _Nullable obj, const char * _Nonnull name,
                           void * _Nullable * _Nullable outValue)
    OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0)
    OBJC_ARC_UNAVAILABLE;

代码:

Person *p1 = [[Person alloc] init];
Ivar ivar = class_getInstanceVariable([p1 class], "_manTest");

禁卫

protocol_getName

/** 
 * Returns the name of a protocol.
 * 
 * @param p A protocol.
 * 
 * @return The name of the protocol e p as a C string.
 */
 根据协议得到协议的名称
OBJC_EXPORT const char * _Nonnull
protocol_getName(Protocol * _Nonnull proto)
    OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);

代码:

Protocol *protocolA = objc_getProtocol("UITableViewDataSource");
NSLog(@"%s", protocol_getName(protocolA));

打印:

TestProject[23900:551699] UITableViewDataSource

游戏的使用者集中:

object_setIvarWithStrongDefault
/** 
 * Sets the value of an instance variable in an object.
 * 
 * @param obj The object containing the instance variable whose value you want to set.
 * @param ivar The Ivar describing the instance variable whose value you want to set.
 * @param value The new value for the instance variable.
 * 
 * @note Instance variables with known memory management (such as ARC strong and weak)
 *  use that memory management. Instance variables with unknown memory management 
 *  are assigned as if they were strong.
 * @note c object_setIvar is faster than c object_setInstanceVariable if the Ivar
 *  for the instance variable is already known.
 */
 // 设置变量中实例变量的值 / iOS 10.0 
OBJC_EXPORT void
object_setIvarWithStrongDefault(id _Nullable obj, Ivar _Nonnull ivar,
                                id _Nullable value) 
    OBJC_AVAILABLE(10.12, 10.0, 10.0, 3.0, 2.0);

代码:

Person *p1 = [[Person alloc] init];
Ivar ivar = class_getInstanceVariable([p1 class], "_manTest");
if (@available(iOS 10.0, *)) {
    object_setIvarWithStrongDefault(p1, ivar, @"chen123");
} else {
    // Fallback on earlier versions
}

骑士

class_respondsToSelector

/** 
 * Returns a Boolean value that indicates whether instances of a class respond to a particular selector.
 * 
 * @param cls The class you want to inspect.
 * @param sel A selector.
 * 
 * @return c YES if instances of the class respond to the selector, otherwise c NO.
 * 
 * @note You should usually use c NSObject's c respondsToSelector: or c instancesRespondToSelector: 
 *  methods instead of this function.
 */
 // 返回一个 Boolean 判断该类是否实现了指定的方法
OBJC_EXPORT BOOL
class_respondsToSelector(Class _Nullable cls, SEL _Nonnull sel) 
    OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);

代码:

BOOL isYES = class_respondsToSelector([self class], @selector(viewWillAppear:));

打印:

(lldb) po isYES
YES

战车鼻部

SEL

多彩冬菇灯

object_dispose

/** 
 * Frees the memory occupied by a given object.
 * 
 * @param obj An Objective-C object.
 * 
 * @return nil
 */
 // 释放给定对象占用的内存
OBJC_EXPORT id _Nullable
object_dispose(id _Nullable obj)
    OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0)
    OBJC_ARC_UNAVAILABLE;

代码:

NSLog(@"%@",object_dispose(p1));

打印:

(lldb) po p1
<Person: 0x60000000ec50>

2018-03-09 17:15:38.690 YZTestProject[24032:6953790] (null)
(lldb) po p1
0x000060000000ec50

代码 shadow_knight

class_isMetaClass
/** 
 * Returns a Boolean value that indicates whether a class object is a metaclass.
 * 
 * @param cls A class object.
 * 
 * @return c YES if e cls is a metaclass, c NO if e cls is a non-meta class, 
 *  c NO if e cls is c Nil.
 */
 // 判断输出的类是否为元类
OBJC_EXPORT BOOL
class_isMetaClass(Class _Nullable cls) 
    OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);

代码:

if (class_isMetaClass(objc_getMetaClass("Cat"))) {
    NSLog(@"YES");
}

打印:

TestProject[41512:7792603] YES

代码 critterlab_kitten

protocol_copyProtocolList

/** 
 * Returns an array of the protocols adopted by a protocol.
 * 
 * @param proto A protocol.
 * @param outCount Upon return, contains the number of elements in the returned array.
 * 
 * @return A C array of protocols adopted by e proto. The array contains e *outCount pointers
 *  followed by a c NULL terminator. You must free the array with c free().
 *  If the protocol declares no properties, c NULL is returned and c *outCount is c 0.
 */
 // 返回协议所遵守的协议,以数组的形式展现
OBJC_EXPORT Protocol * __unsafe_unretained _Nonnull * _Nullable
protocol_copyProtocolList(Protocol * _Nonnull proto,
                          unsigned int * _Nullable outCount)
    OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);

代码:

Protocol *protocolA = objc_getProtocol("CatDelegate");
unsigned int outCount;
Protocol **protocolList = protocol_copyProtocolList(protocolA, &outCount);
for (unsigned int i = 0; i < outCount; i  ) {
    Protocol *protocol = protocolList[I];
    NSLog(@"name --- %s", protocol_getName(protocol));
}

打印:

TestProject[26997:828030] name --- NSObject

蜂王浆

代码 beequeenhivegrown

objc_lookUpClass
/** 
 * Returns the class definition of a specified class.
 * 
 * @param name The name of the class to look up.
 * 
 * @return The Class object for the named class, or c nil if the class
 *  is not registered with the Objective-C runtime.
 * 
 * @note c objc_getClass is different from this function in that if the class is not
 *  registered, c objc_getClass calls the class handler callback and then checks a second
 *  time to see whether the class is registered. This function does not call the class handler callback.
 */
 // 获取指定的类,如果没有注册则返回 nil
OBJC_EXPORT Class _Nullable
objc_lookUpClass(const char * _Nonnull name)
    OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);

代码:

Class cl1 = objc_lookUpClass("Ca");
Class cl2 = objc_lookUpClass("Cat");

冷冻虫卵

objc_class

代码 moonrocknugget

objc_getAssociatedObject

/** 
 * Returns the value associated with a given object for a given key.
 * 
 * @param object The source object for the association.
 * @param key The key for the association.
 * 
 * @return The value associated with the key e key for e object.
 * 
 * @see objc_setAssociatedObject
 */
 // 通过对象和 key 得到一个关联值
OBJC_EXPORT id _Nullable
objc_getAssociatedObject(id _Nonnull object, const void * _Nonnull key)
    OBJC_AVAILABLE(10.6, 3.1, 9.0, 1.0, 2.0);

代码 opalstaff

objc_property_t

跻身娱乐后按“~”键调出调节台;

objc_property_t

定义:

/// An opaque type that represents an Objective-C declared property.
typedef struct objc_property *objc_property_t;

代码 mushroom_farm

protocol_addProtocol

/** 
 * Adds an incorporated protocol to another protocol. The protocol being
 * added to must still be under construction, while the additional protocol
 * must be already constructed.
 * 
 * @param proto The protocol you want to add to, it must be under construction.
 * @param addition The protocol you want to incorporate into e proto, it must be registered.
 */
 // 添加一个已注册的协议到未注册的协议当中
 proto:未注册的协议
 addition:被添加的已注册协议

OBJC_EXPORT void
protocol_addProtocol(Protocol * _Nonnull proto, Protocol * _Nonnull addition) 
    OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0, 2.0);

代码:

// 声明一个协议返回协议的实例
Protocol *protocol = objc_allocateProtocol("ProjectDelegate");
objc_registerProtocol(protocol);   // 协议方法已经注册

Protocol *testProtocol = objc_allocateProtocol("TestProtocol");
protocol_addProtocol(testProtocol, protocol);

// 打印这个协议遵循的协议组
unsigned int count;
Protocol **protocolList = protocol_copyProtocolList(testProtocol, &count);
for (unsigned int i = 0; i < count; i  ) {
    Protocol *protocolC = protocolList[I];
    NSLog(@"name --- %s", protocol_getName(protocolC));
}

打印:

TestProject[32945:1206976] name --- ProjectDelegate

霓虹软糖

class_getInstanceMethod

/** 
 * Returns a specified instance method for a given class.
 * 
 * @param cls The class you want to inspect.
 * @param name The selector of the method you want to retrieve.
 * 
 * @return The method that corresponds to the implementation of the selector specified by 
 *  e name for the class specified by e cls, or c NULL if the specified class or its 
 *  superclasses do not contain an instance method with the specified selector.
 *
 * @note This function searches superclasses for implementations, whereas c class_copyMethodList does not.
 */
 // 获取类的实例化方法
OBJC_EXPORT Method _Nullable
class_getInstanceMethod(Class _Nullable cls, SEL _Nonnull name)
    OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);

代码:

Method methodI = class_getInstanceMethod([self class], @selector(viewWillAppear:));

打印:

(lldb) po methodI
0x000000010ca31528

六安石乔木

ca888会员登录,protocol_copyMethodDescriptionList

/** 
 * Returns an array of method descriptions of methods meeting a given specification for a given protocol.
 * 
 * @param p A protocol.
 * @param isRequiredMethod A Boolean value that indicates whether returned methods should
 *  be required methods (pass YES to specify required methods).
 * @param isInstanceMethod A Boolean value that indicates whether returned methods should
 *  be instance methods (pass YES to specify instance methods).
 * @param outCount Upon return, contains the number of method description structures in the returned array.
 * 
 * @return A C array of c objc_method_description structures containing the names and types of e p's methods 
 *  specified by e isRequiredMethod and e isInstanceMethod. The array contains c *outCount pointers followed
 *  by a c NULL terminator. You must free the list with c free().
 *  If the protocol declares no methods that meet the specification, c NULL is returned and c *outCount is 0.
 * 
 * @note Methods in other protocols adopted by this protocol are not included.
 */
 // 得到方法描述列表
OBJC_EXPORT struct objc_method_description * _Nullable
protocol_copyMethodDescriptionList(Protocol * _Nonnull proto,
                                   BOOL isRequiredMethod,
                                   BOOL isInstanceMethod,
                                   unsigned int * _Nullable outCount)
    OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);

代码:

unsigned int outCount;
struct objc_method_description *descList = protocol_copyMethodDescriptionList(protocolA, YES, YES, &outCount);
for (unsigned int i = 0; i < outCount; i  ) {
    struct objc_method_description desc = descList[I];
    char *types = desc.types;
    NSLog(@"name: %@, type: %s", NSStringFromSelector(desc.name), types);
}

打印:

TestProject[25150:681145] name: tableView:numberOfRowsInSection:, type: q32@0:8@16q24
TestProject[25150:681145] name: tableView:cellForRowAtIndexPath:, type: @32@0:8@16@24

代码 shadow_rook

定义
/// An opaque type that represents a method selector.
typedef struct objc_selector *SEL;

代码 chesspiece_formal_marble/stone

class_getMethodImplementation_stret

/** 
 * Returns the function pointer that would be called if a particular 
 * message were sent to an instance of a class.
 * 
 * @param cls The class you want to inspect.
 * @param name A selector.
 * 
 * @return The function pointer that would be called if c [object name] were called
 *  with an instance of the class, or c NULL if e cls is c Nil.
 */
 // 返回方法的具体的实现
OBJC_EXPORT IMP _Nullable
class_getMethodImplementation_stret(Class _Nullable cls, SEL _Nonnull name) 
    OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0)
    OBJC_ARM64_UNAVAILABLE;

代码:

打印:

ca888会员登录 8

class_getInstanceVariable
/** 
 * Returns the c Ivar for a specified instance variable of a given class.
 * 
 * @param cls The class whose instance variable you wish to obtain.
 * @param name The name of the instance variable definition to obtain.
 * 
 * @return A pointer to an c Ivar data structure containing information about 
 *  the instance variable specified by e name.
 */
OBJC_EXPORT Ivar _Nullable
class_getInstanceVariable(Class _Nullable cls, const char * _Nonnull name)
    OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);

代码:

Person *p1 = [[Person alloc] init];
Ivar ivar = class_getInstanceVariable([p1 class], "_manTest");

打印:

(lldb) po ivar
0x00000001098a1460

野猪

sel_getUid
/** 
 * Registers a method name with the Objective-C runtime system.
 * 
 * @param str A pointer to a C string. Pass the name of the method you wish to register.
 * 
 * @return A pointer of type SEL specifying the selector for the named method.
 * 
 * @note The implementation of this method is identical to the implementation of c sel_registerName.
 * @note Prior to OS X version 10.0, this method tried to find the selector mapped to the given name
 *  and returned c NULL if the selector was not found. This was changed for safety, because it was
 *  observed that many of the callers of this function did not check the return value for c NULL.
 */
// 向 runtime系统根据字符串注册一个方法,返回SEL
OBJC_EXPORT SEL _Nonnull sel_getUid(const char * _Nonnull str)
    OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);

代码:

((void (*)(id, SEL))(void *)objc_msgSend)((id)self, sel_getUid("testFormat"));

打印:

TestProject[22472:6820361] testFormat

小浣猫

objc_method_description

结构:

/// Defines a method
struct objc_method_description {
    SEL _Nullable name;               /**< The name of the method */
    char * _Nullable types;           /**< The types of the method arguments */
};

ca888会员登录 9

定义
/// An opaque type that represents an instance variable.
typedef struct objc_ivar *Ivar;

(marble为浅绿灰 stone为深青莲,输入代码时请自行依据事态更换颜色)

定义

/// An opaque type that represents a category.
typedef struct objc_category *Category;

拖延农场

class_getClassMethod

/** 
 * Returns a pointer to the data structure describing a given class method for a given class.
 * 
 * @param cls A pointer to a class definition. Pass the class that contains the method you want to retrieve.
 * @param name A pointer of type c SEL. Pass the selector of the method you want to retrieve.
 * 
 * @return A pointer to the c Method data structure that corresponds to the implementation of the 
 *  selector specified by aSelector for the class specified by aClass, or NULL if the specified 
 *  class or its superclasses do not contain an instance method with the specified selector.
 *
 * @note Note that this function searches superclasses for implementations, 
 *  whereas c class_copyMethodList does not.
 */
 // 获取类方法
OBJC_EXPORT Method _Nullable
class_getClassMethod(Class _Nullable cls, SEL _Nonnull name)
    OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);

代码:

Method method = class_getClassMethod([Person class], @selector(test));

打印:

(lldb) po method
0x0000000106c633d8

并日而食联机版代码大全 联机版调控台秘技

class_conformsToProtocol

/** 
 * Returns a Boolean value that indicates whether a class conforms to a given protocol.
 * 
 * @param cls The class you want to inspect.
 * @param protocol A protocol.
 *
 * @return YES if cls conforms to protocol, otherwise NO.
 *
 * @note You should usually use NSObject's conformsToProtocol: method instead of this function.
 */
// 返回一个 Boolean 值,检查某个类是否遵从某个协议
OBJC_EXPORT BOOL
class_conformsToProtocol(Class _Nullable cls, Protocol * _Nullable protocol) 
    OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);

代码:

Protocol *protocol = NSProtocolFromString(@"UITableViewDataSource");
BOOL isConforms = class_conformsToProtocol([UITableViewController class], protocol);

打印:

(lldb) po isConforms
YES

战车

定义
/// An opaque type that represents a method in a class definition.
typedef struct objc_method *Method;

呼月基座

method_exchangeImplementations

Method method1 = class_getInstanceMethod([NSString class], @selector(lowercaseString));
Method method2 = class_getInstanceMethod([NSString class], @selector(uppercaseString));
method_exchangeImplementations(method1, method2);//交换两个方法后,两个方法的功能相反

木栅栏

Method

代码 canary

objc_getMetaClass
/** 
 * Returns the metaclass definition of a specified class.
 * 
 * @param name The name of the class to look up.
 * 
 * @return The c Class object for the metaclass of the named class, or c nil if the class
 *  is not registered with the Objective-C runtime.
 * 
 * @note If the definition for the named class is not registered, this function calls the class handler
 *  callback and then checks a second time to see if the class is registered. However, every class
 *  definition must have a valid metaclass definition, and so the metaclass definition is always returned,
 *  whether it’s valid or not.
 */
 // 得到一个类的元类
OBJC_EXPORT Class _Nullable
objc_getMetaClass(const char * _Nonnull name)
    OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);

代码:

Cat *cat1 = [[Cat alloc] init];
Class c1 = objc_getMetaClass("Cat");
NSLog(@"%@", c1);
NSLog(@"%@", cat1.name);

打印:

TestProject[25712:7077004] Cat
TestProject[25712:7077004] testH

代码 endtable

objc_copyImageNames

/* Working with Libraries */

/** 
 * Returns the names of all the loaded Objective-C frameworks and dynamic
 * libraries.
 * 
 * @param outCount The number of names returned.
 * 
 * @return An array of C strings of names. Must be free()'d by caller.
 */
 // 返回所有已加载的 Objective-C 框架和动态库的名称
OBJC_EXPORT const char * _Nonnull * _Nonnull
objc_copyImageNames(unsigned int * _Nullable outCount) 
    OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);

代码:

unsigned int outCount;
const char **nameList = objc_copyImageNames(&outCount);
for (unsigned int i = 0; i < outCount; i  ) {
    const char *name = nameList[I];
    NSLog(@"name : %s", name);
}
free(nameList);

打印:

TestProject[34100:1278609] name : /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 10.2.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection/libdispatch.dylib
TestProject[34100:1278609] name : /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 10.2.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libxpc.dylib
TestProject[34100:1278609] name : /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 10.2.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libsystem_trace.dylib
TestProject[34100:1278609] name : /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 10.2.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libsystem_network.dylib
TestProject[34100:1278609] name : /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 10.2.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libobjc.A.dylib
TestProject[34100:1278609] name : /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 10.2.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libate.dylib

饔飧不济手提式无线电话机版怎么作弊 手提式有线电话机版作弊教程

class_getSuperclass
/** 
 * Returns the superclass of a class.
 * 
 * @param cls A class object.
 * 
 * @return The superclass of the class, or c Nil if
 *  e cls is a root class, or c Nil if e cls is c Nil.
 *
 * @note You should usually use c NSObject's c superclass method instead of this function.
 */
 // 得到这个类的父类
OBJC_EXPORT Class _Nullable
class_getSuperclass(Class _Nullable cls) 
    OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);

代码:

NSLog(@"%@", class_getSuperclass([self class]));

打印:

TestProject[41571:7797664] UIViewController

代码 fence

class_getImageName

/** 
 * Returns the dynamic library name a class originated from.
 * 
 * @param cls The class you are inquiring about.
 * 
 * @return The name of the library containing this class.
 */
 // 返回这个类 源动态库名称
OBJC_EXPORT const char * _Nullable
class_getImageName(Class _Nullable cls) 
    OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);

代码:

const char *libraryName = class_getImageName([UIViewController class]);
NSLog(@"name: %s", libraryName);

打印:

TestProject[34267:1284976] name: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 10.2.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/UIKit.framework/UIKit

地图卷轴

class_copyIvarList
/** 
 * Describes the instance variables declared by a class.
 * 
 * @param cls The class to inspect.
 * @param outCount On return, contains the length of the returned array. 
 *  If outCount is NULL, the length is not returned.
 * 
 * @return An array of pointers of type Ivar describing the instance variables declared by the class. 
 *  Any instance variables declared by superclasses are not included. The array contains *outCount 
 *  pointers followed by a NULL terminator. You must free the array with free().
 * 
 *  If the class declares no instance variables, or cls is Nil, NULL is returned and *outCount is 0.
 */
 // 一个 Ivar 类型的指针数组,用于描述该类声明的实例变量,必须用free释放该数组
OBJC_EXPORT Ivar _Nonnull * _Nullable
class_copyIvarList(Class _Nullable cls, unsigned int * _Nullable outCount) 
    OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);

代码:

unsigned int count;
Ivar *ivars = class_copyIvarList([Person class], &count);
for (unsigned int i = 0; i < count; i  ) {
    Ivar ivar = ivars[I];
    const char *name = ivar_getName(ivar);
    const char *type = ivar_getTypeEncoding(ivar);
    NSLog(@"类型为%s 的 %s", type, name);

}
free(ivars);

打印:

TestProject[42937:7913951] 类型为@"NSString" 的 _manTest

蘑菇灯

ivar_getName
/* Working with Instance Variables */

/** 
 * Returns the name of an instance variable.
 * 
 * @param v The instance variable you want to enquire about.
 * 
 * @return A C string containing the instance variable's name.
 */

 // 返回实时变量的名称

OBJC_EXPORT const char * _Nullable
ivar_getName(Ivar _Nonnull v) 
    OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);

代码:

Person *p1 = [[Person alloc] init];
Ivar ivar = object_getInstanceVariable(p1, "_manTest", nil);
NSLog(@"%s", ivar_getName(ivar));

打印:

TestProject[22909:6849954] _manTest

毒蕈皮

protocol_isEqual

/** 
 * Returns a Boolean value that indicates whether two protocols are equal.
 * 
 * @param proto A protocol.
 * @param other A protocol.
 * 
 * @return c YES if e proto is the same as e other, otherwise c NO.
 */
 // 判断两个协议是否相等
OBJC_EXPORT BOOL
protocol_isEqual(Protocol * _Nullable proto, Protocol * _Nullable other)
    OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);

代码:

Protocol *protocolA = objc_getProtocol("UITableViewDataSource");
Protocol *protocolB = NSProtocolFromString(@"UITableViewDataSource");
BOOL isEqual = protocol_isEqual(protocolA, protocolB);

打印:

(lldb) po isEqual
YES

ca888会员登录 10

objc_property_attribute_t

结构:

/// Defines a property attribute
typedef struct {
    const char * _Nonnull name;           /**< The name of the attribute */
    const char * _Nonnull value;          /**< The value of the attribute (usually empty) */
} objc_property_attribute_t;

更加多优质计策,请关怀4399饔飧不继战术专区,只怕在百度上寻觅“4399饥荒,找到大家的专区,就能够在第不常间获得饔飧不济的风靡相关内容。

objc_copyProtocolList

/** 
 * Returns an array of all the protocols known to the runtime.
 * 
 * @param outCount Upon return, contains the number of protocols in the returned array.
 * 
 * @return A C array of all the protocols known to the runtime. The array contains c *outCount
 *  pointers followed by a c NULL terminator. You must free the list with c free().
 * 
 * @note This function acquires the runtime lock.
 */
 // 返回运行时系统所有的协议
OBJC_EXPORT Protocol * __unsafe_unretained _Nonnull * _Nullable
objc_copyProtocolList(unsigned int * _Nullable outCount)
    OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);

代码:

unsigned int outCount;
Protocol **protocolList = objc_copyProtocolList(&outCount);
for (unsigned int i = 0; i < outCount; i  ) {
    Protocol *protocol = protocolList[I];
    NSLog(@"%s", protocol_getName(protocol));
}

打印:

TestProject[23401:517412] UIVideoEditorControllerDelegate
TestProject[23401:517412] _UIIVCResponseDelegate
TestProject[23401:517412] _UITouchable
TestProject[23401:517412] WebOpenPanelResultListener
TestProject[23401:517412] SBSRemoteAlertClientHandle
TestProject[23401:517412] _UIContentContainerInternal
TestProject[23401:517412] _UIKeyboardAutoRespondingScrollView
TestProject[23401:517412] CAMLWriterDelegate
TestProject[23401:517412] OS_nw_endpoint_resolver
TestProject[23401:517412] _UIActivityHelperDelegate

代码 dragonflyfurnace

方法

Mini主教象棋紫罗兰色/青蓝

objc_registerProtocol

/** 
 * Registers a newly constructed protocol with the runtime. The protocol
 * will be ready for use and is immutable after this.
 * 
 * @param proto The protocol you want to register.
 */
 // 注册协议
OBJC_EXPORT void
objc_registerProtocol(Protocol * _Nonnull proto) 
    OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0, 2.0);

代码:

Protocol *protocol = objc_allocateProtocol("PersonDelegate");
// 声明这个协议还是不可以用的,还是要注册这个协议的
objc_registerProtocol(protocol);

打印:

(lldb) po protocol
<Protocol: 0x6080000a84c0>

主教

objc_allocateClassPair

/* Adding Classes */

/** 
 * Creates a new class and metaclass.
 * 
 * @param superclass The class to use as the new class's superclass, or c Nil to create a new root class.
 * @param name The string to use as the new class's name. The string will be copied.
 * @param extraBytes The number of bytes to allocate for indexed ivars at the end of 
 *  the class and metaclass objects. This should usually be c 0.
 * 
 * @return The new class, or Nil if the class could not be created (for example, the desired name is already in use).
 * 
 * @note You can get a pointer to the new metaclass by calling c object_getClass(newClass).
 * @note To create a new class, start by calling c objc_allocateClassPair. 
 *  Then set the class's attributes with functions like c class_addMethod and c class_addIvar.
 *  When you are done building the class, call c objc_registerClassPair. The new class is now ready for use.
 * @note Instance methods and instance variables should be added to the class itself. 
 *  Class methods should be added to the metaclass.
 */
功能:创建一个新的类和这个元类
去创建一个新的类开始通过objc_allocateClassPair,然后设置类的属性和功能用class_addMethod和class_addIvar,实例化方法和实例化变量应该被添加到类本身,类应该添加到元类中。
OBJC_EXPORT Class _Nullable
objc_allocateClassPair(Class _Nullable superclass, const char * _Nonnull name, 
                       size_t extraBytes) 
    OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);

代码 royal_jelly

Protocol

定义:

typedef struct objc_object Protocol;

疑惑咸宁石种类

objc_getRequiredClass
/** 
 * Returns the class definition of a specified class.
 * 
 * @param name The name of the class to look up.
 * 
 * @return The Class object for the named class.
 * 
 * @note This function is the same as c objc_getClass, but kills the process if the class is not found.
 * @note This function is used by ZeroLink, where failing to find a class would be a compile-time link error without ZeroLink.
 */
 // 获取指定类,如果这个类不存在则崩溃
OBJC_EXPORT Class _Nonnull
objc_getRequiredClass(const char * _Nonnull name)
    OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);

代码:

Class cl1 = objc_getRequiredClass("Ca");

ca888会员登录 11

方法

阴影骑士

object_copy

/** 
 * Returns a copy of a given object.
 * 
 * @param obj An Objective-C object.
 * @param size The size of the object e obj.
 * 
 * @return A copy of e obj.
 */
// 对象的 copy 属于深 copy
OBJC_EXPORT id _Nullable object_copy(id _Nullable obj, size_t size)
    OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0)
    OBJC_ARC_UNAVAILABLE;

代码:

NSLog(@"self --- %p", self);
NSLog(@"object_copy --- %p", object_copy(self, sizeof(self)));

打印:

TestProject[23793:6934176] self --- 0x7f9f8c4049e0
TestProject[23793:6934176] object_copy --- 0x7f9f8c70a1d0

巨型蜂巢

object_setClass
/** 
 * Sets the class of an object.
 * 
 * @param obj The object to modify.
 * @param cls A class object.
 * 
 * @return The previous value of e object's class, or c Nil if e object is c nil.
 */
OBJC_EXPORT Class _Nullable
object_setClass(id _Nullable obj, Class _Nonnull cls) 
    OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);

代码:

Person *p1 = [[Person alloc] init];
NSLog(@"n p1 = %@", p1);
Class c1 = object_setClass(p1, [Cat class]);
NSLog(@"n c1 = %@ n p1 = %@", c1, p1);

打印:

TestProject[24490:6987169] 
 p1 = <Person: 0x60000000a580>
TestProject[24490:6987169] 
 c1 = Person 
 p1 = <Cat: 0x60000000a580>

版权声明:本文由ca888发布于ca888圈内,转载请注明出处:Runtime 源码解析