我在我的项目中使用了一个名为SKSTableView的简洁表视图控制器,它允许每个表行有多个子行。此代码在32 位模式下完美运行,但当我在 iPhone 5S 或模拟器中以 4 英寸 64 位模式运行它时,当您点击一行以获取子行时,它会崩溃。我对 64 位和 32 位 iOS 系统的区别一无所知。我很想了解这里发生了什么。
您会注意到 *SubRowObjectKey 设置为 void - 我得到的错误是:
EXC_BAD_ACCESS_(code=EXC_I386_GPFLT)
这是试图访问不存在的东西的一般保护错误(?)
当它崩溃时,Xcode 会突出显示这行代码:objc_setAssociatedObject(self, SubRowObjectKey, subRowObj, OBJC_ASSOCIATION_ASSIGN);
Also there is this:
Printing description of *(subRowObj):
(id) [0] =
Printing description of SubRowObjectKey:
It seems to be working great in 32bit mode but some how in 64bit it seems to loose where it is. Here below is the section of the code I am looking at.
#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;
}
您可以在此处下载并使用代码:https ://github.com/sakkaras/SKSTableView