我在我的项目中使用一个名为SKSTableView的整洁的表视图控制器,它允许每个表行具有多个子行.这段代码在32位模式下运行完美,但是当我在iPhone 5S或4英寸64位模式的模拟器中运行时,当你点击一行来获取子行时它会崩溃.我对64位和32位iOS系统的差异一无所知.我很想知道这里发生了什么.
您会注意到*SubRowObjectKey设置为void-我得到的错误是:
EXC_BAD_ACCESS_(code = EXC_I386_GPFLT)
这是一个一般保护错误,试图访问不存在的东西(?)
当它崩溃Xcode突出显示这行代码时__CODE__:
#pragma mark - NSIndexPath (SKSTableView)
static void *SubRowObjectKey;
@implementation NSIndexPath (SKSTableView)
@dynamic subRow;
- (NSInteger)subRow
{
id subRowObj = objc_getAssociatedObject(self, SubRowObjectKey);
return [subRowObj integerValue];
}
- (void)setSubRow:(NSInteger)subRow
{
if (IsEmpty(@(subRow))) {
return;
}
id subRowObj = @(subRow);
objc_setAssociatedObject(self, SubRowObjectKey, subRowObj, OBJC_ASSOCIATION_ASSIGN);
}
+ (NSIndexPath *)indexPathForSubRow:(NSInteger)subrow inRow:(NSInteger)row inSection:(NSInteger)section
{
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section];
indexPath.subRow = subrow;
return indexPath;
}
Run Code Online (Sandbox Code Playgroud)
