来自非公共API的'NSIntersectsRect'吗?如果是这样,还有其他选择吗?

时间:2012-01-31 06:16:48

标签: objective-c xcode api public

我正在将上述类用于我尝试提交到应用商店的应用。它给出了错误“应用程序引用了Payload / 应用程序名称中的非公共符号 .app / 应用程序名称:NSIntersectsRect”。如果这是非公开的,有没有人知道可以提供相同功能的类(即检测矩形是否与另一个重叠),或者我是否需要找出自定义的解决方法?

2 个答案:

答案 0 :(得分:1)

根据NSIntersectionRect的文档

If the two rectangles don’t overlap, the returned rectangle has its origin at (0.0, 0.0) and zero width and height (including situations where the intersection is a point or a line segment)

所以我的建议是创建一个类似

的方法
- (BOOL)rect:(NSRect)rect1 intersectsRect:(NSRect)rect2 {
    NSRect testRect = NSIntersectionRect(rect1, rect2);
    return !NSEqualRects(testRect, NSMakeRect(0.0, 0.0, 0.0, 0.0)
}

答案 1 :(得分:1)

听起来像是一个错误......无论如何 - CGRectIntersectsRect怎么样?