当前位置:首页 > Windows程序 > 正文

通过标准的Runtime API(C函数)打印UIKit中UIView的所有变量、属性以及方法

2021-03-26 Windows程序

Ivar:定义对象的实例变量,,包括类型和名字。
objc_property_t:定义属性。叫这个名字可能是为了防止和Objective-C 1.0中的用户类型冲突,那时候还没有属性。
Method:定义对象方法或类方法。这个类型提供了方法的名字(就是**选择器**)、参数数量和类型,以及返回值(这些信息合起来称为方法的**签名**),还有一个指向代码的函数指针(也就是方法的**实现**)。
SEL:定义选择器。选择器是方法名的唯一标识符,我理解它就是个字符串。


下面是一些运行代码和对应日止

+ (void)printIvarList { u_int count; Ivar *ivarlist = class_copyIvarList([UIView class], &count); for (int i = 0; i < count; i++) { const char *ivarName = ivar_getName(ivarlist[i]); NSString *strName = [NSString stringWithCString:ivarName encoding:NSUTF8StringEncoding]; NSLog(@"ivarName:%@", strName); } } + (void)printPropertyList { u_int count; objc_property_t *properties = class_copyPropertyList([UIView class], &count); for (int i = 0; i < count; i++) { const char *propertyName = property_getName(properties[i]); NSString *strName = [NSString stringWithCString:propertyName encoding:NSUTF8StringEncoding]; NSLog(@"propertyName:%@", strName); } } + (void)printMethodList { u_int count; Method *methods = class_copyMethodList([UIView class], &count); for (int i = 0; i < count; i++) { SEL methodName = method_getName(methods[i]); NSString *strName = [NSString stringWithCString:sel_getName(methodName) encoding:NSUTF8StringEncoding]; NSLog(@"methodName:%@", strName); } }

printIvarList

2015-09-08 11:11:21.976 test7[11804:403582] ivarName:_layer 2015-09-08 11:11:21.976 test7[11804:403582] ivarName:_gestureInfo 2015-09-08 11:11:21.976 test7[11804:403582] ivarName:_gestureRecognizers 2015-09-08 11:11:21.976 test7[11804:403582] ivarName:_subviewCache 2015-09-08 11:11:21.976 test7[11804:403582] ivarName:_charge 2015-09-08 11:11:21.977 test7[11804:403582] ivarName:_tag 2015-09-08 11:11:21.977 test7[11804:403582] ivarName:_viewDelegate 2015-09-08 11:11:21.977 test7[11804:403582] ivarName:_backgroundColorSystemColorName 2015-09-08 11:11:21.977 test7[11804:403582] ivarName:_countOfMotionEffectsInSubtree 2015-09-08 11:11:21.977 test7[11804:403582] ivarName:_countOfTraitChangeRespondersInDirectSubtree 2015-09-08 11:11:21.977 test7[11804:403582] ivarName:_viewFlags 2015-09-08 11:11:21.977 test7[11804:403582] ivarName:_retainCount 2015-09-08 11:11:21.977 test7[11804:403582] ivarName:_tintAdjustmentDimmingCount 2015-09-08 11:11:21.977 test7[11804:403582] ivarName:_shouldArchiveUIAppearanceTags 2015-09-08 11:11:21.977 test7[11804:403582] ivarName:_interactionTintColor 2015-09-08 11:11:21.980 test7[11804:403582] ivarName:_minXVariable 2015-09-08 11:11:21.980 test7[11804:403582] ivarName:_minYVariable 2015-09-08 11:11:21.980 test7[11804:403582] ivarName:_boundsWidthVariable 2015-09-08 11:11:21.980 test7[11804:403582] ivarName:_boundsHeightVariable 2015-09-08 11:11:21.980 test7[11804:403582] ivarName:_layoutEngine 2015-09-08 11:11:21.980 test7[11804:403582] ivarName:_layoutDebuggingIdentifier 2015-09-08 11:11:21.980 test7[11804:403582] ivarName:_internalConstraints 2015-09-08 11:11:21.980 test7[11804:403582] ivarName:_constraintsExceptingSubviewAutoresizingConstraints 2015-09-08 11:11:21.980 test7[11804:403582] ivarName:__presentationControllerToNotifyOnLayoutSubviews 2015-09-08 11:11:21.980 test7[11804:403582] ivarName:_rawLayoutMargins 2015-09-08 11:11:21.980 test7[11804:403582] ivarName:_inferredLayoutMargins

printPropertyList


2015-09-08 11:17:23.841 test7[11919:412660] propertyName:artworkCatalog 2015-09-08 11:17:23.841 test7[11919:412660] propertyName:focusDirection 2015-09-08 11:17:23.841 test7[11919:412660] propertyName:_mayRemainFocused 2015-09-08 11:17:23.841 test7[11919:412660] propertyName:skipsSubviewEnumeration 2015-09-08 11:17:23.841 test7[11919:412660] propertyName:viewTraversalMark 2015-09-08 11:17:23.841 test7[11919:412660] propertyName:viewDelegate 2015-09-08 11:17:23.841 test7[11919:412660] propertyName:monitorsSubtree 2015-09-08 11:17:23.841 test7[11919:412660] propertyName:backgroundColorSystemColorName 2015-09-08 11:17:23.841 test7[11919:412660] propertyName:currentScreenScale 2015-09-08 11:17:23.841 test7[11919:412660] propertyName:maskView 2015-09-08 11:17:23.841 test7[11919:412660] propertyName:_userInterfaceIdiom 2015-09-08 11:17:23.841 test7[11919:412660] propertyName:hash 2015-09-08 11:17:23.841 test7[11919:412660] propertyName:superclass 2015-09-08 11:17:23.841 test7[11919:412660] propertyName:description 2015-09-08 11:17:23.841 test7[11919:412660] propertyName:debugDescription 2015-09-08 11:17:23.841 test7[11919:412660] propertyName:gesturesEnabled 2015-09-08 11:17:23.842 test7[11919:412660] propertyName:deliversTouchesForGesturesToSuperview 2015-09-08 11:17:23.842 test7[11919:412660] propertyName:_inheritedRenderConfig 2015-09-08 11:17:23.842 test7[11919:412660] propertyName:_lightStyleRenderConfig 2015-09-08 11:17:23.842 test7[11919:412660] propertyName:_accessoryViewFrame 2015-09-08 11:17:23.842 test7[11919:412660] propertyName:unsatisfiableConstraintsLoggingSuspended 2015-09-08 11:17:23.842 test7[11919:412660] propertyName:hash 2015-09-08 11:17:23.842 test7[11919:412660] propertyName:superclass 2015-09-08 11:17:23.842 test7[11919:412660] propertyName:description 2015-09-08 11:17:23.842 test7[11919:412660] propertyName:debugDescription 2015-09-08 11:17:23.842 test7[11919:412660] propertyName:hash 2015-09-08 11:17:23.842 test7[11919:412660] propertyName:superclass 2015-09-08 11:17:23.842 test7[11919:412660] propertyName:description 2015-09-08 11:17:23.842 test7[11919:412660] propertyName:debugDescription 2015-09-08 11:17:23.842 test7[11919:412660] propertyName:userInteractionEnabled 2015-09-08 11:17:23.842 test7[11919:412660] propertyName:tag 2015-09-08 11:17:23.842 test7[11919:412660] propertyName:layer 2015-09-08 11:17:23.842 test7[11919:412660] propertyName:interactionTintColor 2015-09-08 11:17:23.842 test7[11919:412660] propertyName:_layoutDebuggingIdentifier 2015-09-08 11:17:23.843 test7[11919:412660] propertyName:focused 2015-09-08 11:17:23.843 test7[11919:412660] propertyName:_countOfMotionEffectsInSubtree 2015-09-08 11:17:23.843 test7[11919:412660] propertyName:_maskView 2015-09-08 11:17:23.843 test7[11919:412660] propertyName:_ancestorDefinesTintColor 2015-09-08 11:17:23.843 test7[11919:412660] propertyName:_ancestorDefinesTintAdjustmentMode 2015-09-08 11:17:23.843 test7[11919:412660] propertyName:_presentationControllerToNotifyOnLayoutSubviews 2015-09-08 11:17:23.843 test7[11919:412660] propertyName:_rawLayoutMargins 2015-09-08 11:17:23.843 test7[11919:412660] propertyName:_inferredLayoutMargins 2015-09-08 11:17:23.843 test7[11919:412660] propertyName:_layoutEngine 2015-09-08 11:17:23.843 test7[11919:412660] propertyName:_boundsWidthVariable 2015-09-08 11:17:23.843 test7[11919:412660] propertyName:_boundsHeightVariable 2015-09-08 11:17:23.843 test7[11919:412660] propertyName:_minXVariable 2015-09-08 11:17:23.843 test7[11919:412660] propertyName:_minYVariable 2015-09-08 11:17:23.843 test7[11919:412660] propertyName:_internalConstraints 2015-09-08 11:17:23.843 test7[11919:412660] propertyName:_constraintsExceptingSubviewAutoresizingConstraints 2015-09-08 11:17:23.843 test7[11919:412660] propertyName:unsatisfiableConstraintsLoggingSuspended 2015-09-08 11:17:23.843 test7[11919:412660] propertyName:_shouldArchiveUIAppearanceTags 2015-09-08 11:17:23.843 test7[11919:412660] propertyName:_interactionTintColor 2015-09-08 11:17:23.844 test7[11919:412660] propertyName:_backdropMaskViewForGrayscaleTint 2015-09-08 11:17:23.844 test7[11919:412660] propertyName:_backdropMaskViewForColorTint 2015-09-08 11:17:23.844 test7[11919:412660] propertyName:_backdropMaskViewForFilters 2015-09-08 11:17:23.844 test7[11919:412660] propertyName:_backdropMaskViews 2015-09-08 11:17:23.844 test7[11919:412660] propertyName:_wantsGeometryChangeNotification 2015-09-08 11:17:23.844 test7[11919:412660] propertyName:hash 2015-09-08 11:17:23.844 test7[11919:412660] propertyName:superclass 2015-09-08 11:17:23.844 test7[11919:412660] propertyName:description 2015-09-08 11:17:23.844 test7[11919:412660] propertyName:debugDescription 2015-09-08 11:17:23.844 test7[11919:412660] propertyName:traitCollection 2015-09-08 11:17:23.844 test7[11919:412660] propertyName:preferredFocusedItem 2015-09-08 11:17:23.844 test7[11919:412660] propertyName:focusedView 2015-09-08 11:17:23.844 test7[11919:412660] propertyName:center 2015-09-08 11:17:23.844 test7[11919:412660] propertyName:bounds 2015-09-08 11:17:23.844 test7[11919:412660] propertyName:transform


温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/67605.html