相关疑难解决方法(0)

将nil发送到CGPoint类型参数

假设我有这个方法:

- (void)placeView:(UIView*)theView withCenterIn:(CGPoint)centerPoint;
Run Code Online (Sandbox Code Playgroud)

所以我将视图和一个点传递给视图的中心.

但碰巧我不需要指定中心,只需要指定视图.

传递"nil"会导致错误.

请建议如何跳过中心点.

请记住,我需要使用这样的方法:

- (void)placeView:(UIView*)theView withCenterIn:(CGPoint)centerPoint{
    if(centerPoint == nil){//and I understand that it's a wrong comparison, as I cannot pass "nil" to CGPoint
        //set a random center point
    }
    else{
        //set that view to the specified point
    }
}
Run Code Online (Sandbox Code Playgroud)

提前致谢

objective-c

5
推荐指数
2
解决办法
4439
查看次数

标签 统计

objective-c ×1