这段代码意味着什么?
[images isKindOfClass:[NSArray class]]
它返回一个布尔值,但为什么我们使用它?
由于
答案 0 :(得分:5)
isKindOfClass
返回true。在这种情况下,它会检查images
是NSArray
还是NSArray
的子类。
我正在处理的一些代码中使用的示例是检查我们正在显示的项目是否需要为iPad([ctrl isKindOfClass:[BaseSplitViewController class]]
)或iPhone处理。像这样:
CGRect backViewFrame = CGRectZero;
if ([currentController isKindOfClass:[BaseSplitViewController class]]) {
//Set width and hight of background View to 1024.
[backgroundView setFrame:CGRectMake(0, 0, 1024, 1024)];
if (UIInterfaceOrientationIsLandscape(orientation)) {
backViewFrame = CGRectMake(0, 0, 1024, 768);
} else if (UIInterfaceOrientationIsPortrait(orientation)) {
backViewFrame = CGRectMake(0, 0, 768, 1024);
}
} else {
backViewFrame = currentController.view.frame;
[backgroundView setFrame:backViewFrame];
}