这段代码意味着什么?
[images isKindOfClass:[NSArray class]]
Run Code Online (Sandbox Code Playgroud)
它返回一个布尔值,但为什么我们使用它?
谢谢
isKindOfClass当对象从(或是)给定类继承时返回true.在这种情况下,它检查是否images是a 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];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
124 次 |
| 最近记录: |