iOS 7移植32位到64位崩溃

时间:2014-03-08 00:14:08

标签: objective-c ios7 32bit-64bit

为什么这段代码会在64位崩溃? - 它工作正常32位。

正在为UIView加载一个笔尖

- (id) awakeAfterUsingCoder:(NSCoder*)aDecoder {

    BOOL theThingThatGotLoadedWasJustAPlaceholder = ([[self subviews] count] == 0);

    if (theThingThatGotLoadedWasJustAPlaceholder) {

        ALTimelineView* theRealThing = [[self class] loadFromNib];

        // pass properties through
        theRealThing.frame = self.frame;
        theRealThing.autoresizingMask = self.autoresizingMask;
        theRealThing.alpha = self.alpha;
        theRealThing.hidden = self.hidden;

        [theRealThing internalInit];

        // convince ARC that we're legit
        CFRelease((__bridge const void*)self);
        CFRetain((__bridge const void*)theRealThing);

        return theRealThing;
    }
    return self;
}

loadFromNib

+ (id) loadFromNib {

    NSString* nibName = NSStringFromClass([self class]);
    NSArray* elements = [[NSBundle mainBundle] loadNibNamed:nibName owner:nil options:nil];

    for (NSObject* anObject in elements) {
        if ([anObject isKindOfClass:[self class]]) {
            return anObject;
        }
    }
    return nil;
}

我得到的错误是EXC_BAD_ACCESS(代码= EXC_I386_GPFLT)

1 个答案:

答案 0 :(得分:2)

EXC_I386_GPFLT肯定是指“一般保护错误”,这是x86告诉你“你做了一件你不允许做的事”的方法。它通常并不意味着您访问内存不足,但可能是您的代码超出范围并导致错误的代码/数据以某种方式导致保护违规。

检查此Reference Link以获取有关EXC_I386_GPFLT

的详细说明