我发现了一个演示片段,它使用了这样的类型转换:(int)view.'view' 是 UIView 对象的指针。我从来不知道它可以用来转换类型。有人可以帮我解释一下吗?在此处粘贴代码
- (CGPoint)accelerationForView:(UIView *)view
{
// return
CGPoint accelecration;
// get acceleration
NSValue *pointValue = [self._accelerationsOfSubViews objectForKey:
[NSNumber numberWithInteger:(int)view]];
if (pointValue == nil) {
accelecration = CGPointZero;
}
else {
[pointValue getValue:&accelecration];
}
return accelecration;
}
- (void)willRemoveSubview:(UIView *)subview
{
[self._accelerationsOfSubViews removeObjectForKey:
[NSNumber numberWithInt:(int)subview]];
}