OC

Knowledge OS
主帖 2 条回复

为什么仅靠引用UIKit.h就可以调用NSIndexPath?

清醒疯子 清醒疯子 · 2014年02月24日 · 无人欣赏。

初步的答案是:

因为UIKit.h里引用了UITableView.h,而UITableView.h里有一个NSIndexPath的Category声明:

@interface NSIndexPath (UITableView)
+ (NSIndexPath *)indexPathForRow:(NSInteger)row inSection:(NSInteger)section;
@property(nonatomic,readonly) NSInteger section;
@property(nonatomic,readonly) NSInteger row;
@end

但为什么要这样搞咧?

回复

2 条
#2
xamppobjc
2014年02月24日

NSIndexPath.h类在Foundation.framework里面声明的。

@interface NSIndexPath : NSObject <NSCopying, NSCoding> {

登录 或者 注册