Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/106.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何检查UIViewController类是定义为SDK的一部分还是用户定义的?_Ios_Objective C - Fatal编程技术网

Ios 如何检查UIViewController类是定义为SDK的一部分还是用户定义的?

Ios 如何检查UIViewController类是定义为SDK的一部分还是用户定义的?,ios,objective-c,Ios,Objective C,是否有方法检查给定的UIViewController是用户定义的还是系统提供的 //The following may be implemented in one of the View Controller lifecycle methods by swizzling NSString *controllerName = NSStringFromClass([self class]); if([Helper controllerIsUserDefined:controllerName]) {

是否有方法检查给定的UIViewController是用户定义的还是系统提供的

//The following may be implemented in one of the View Controller lifecycle methods by swizzling
NSString *controllerName = NSStringFromClass([self class]);
if([Helper controllerIsUserDefined:controllerName]) {
     //Let us do this only for user-defined UIViewController classes
}

我正在寻找一种实现
controllerIsUserDefined
方法的方法。此外,我不喜欢在用户定义的ViewController类中添加虚拟属性或方法,然后使用
respondsToSelector
进行检查,因为此功能也可能在现有项目中使用

您可以检查主捆绑包中是否定义了类,这可能会解决您的问题

if ([[NSBundle mainBundle] isEqual:[NSBundle bundleForClass:[self class]]]) {
    // Object class defined in the main bundle
}

如果类是在用户提供的框架中定义的,这可能不起作用。

非常好,非常感谢。这对我来说很好,我不希望任何用户提供的框架在我的用例中扮演角色。