objc-setassociatedobject-function-error-in-64bit-mode-not-in-32bit


链接:https://github.com/sakkaras/SKSTableView/issues/2


ok guys , there is simple and elegant solution to solve this :) 
little explanation :
On iOS for arm64, the isa field of Objective-C objects is no longer a pointer. 
Some of the bits still encode the pointer to the object's class. But neither OS X nor iOS actually uses all 64 bits of virtual address space. The Objective-C runtime may use these extra bits to store per-object data like its retain count or whether it has been weakly referenced.
They changed "this" to 64bit becouse performance. Re-purposing these otherwise unused bits increases speed and decreases memory size. On iOS 7 the focus is on optimizing retain/release and alloc/dealloc.

from that REASON DON'T

1. read obj->isa directly. The compiler will complain if you do. Trust the Compiler. The Compiler is your friend. Use [obj class] or object_getClass(obj) instead.
2.Don't write obj->isa directly. Use object_setClass() instead.

from that reason you need to change "way" you setting in 2 methods . 
example .

  • (NSInteger)subRow
    {
    id myclass = [SKSTableView class];


    id subRowObj = objc_getAssociatedObject(myclass, SubRowObjectKey);
    return [subRowObj integerValue];
    }

  • (void)setSubRow:(NSInteger)subRow
    {
    id subRowObj = [NSNumber numberWithInteger:subRow];

    id myclass = [SKSTableView class];

    objc_setAssociatedObject(myclass, nil, subRowObj, OBJC_ASSOCIATION_RETAIN_NONATOMIC);

}
so put example for setSubRow and subRow , id myclass = [SKSTableView class]; 
objc_getAssociatedObject(myclass, SubRowObjectKey);
and 
for objc_setAssociatedObject(myclass, nil, subRowObj, OBJC_ASSOCIATION_RETAIN_NONATOMIC);

self-->isa IS PROBLEM on arm64 on iOS .

This works for 32bits and 64bit arch :)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值