mbogh / NibDesignable

Elegant way of enabling IBDesignable on your nib-based views
MIT License
342 stars 74 forks source link

init(coder aDecoder:NSCoder) crashing with EXC_BAD_ACCESS(code=2) on XCode 6.4 #10

Closed lovince closed 9 years ago

lovince commented 9 years ago

My custom view from NibDesignable is crashing on line 64 of NibDesignable.swift

    // MARK: - NSCoding
    required public init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)  // line 64
        self.setupNib()
    }

with EXC_BAD_ACCESS(code=2) when the view gets instantiated at run time. Placing breakpoints on the line suggests an infinite loop of sorts where the initializer gets called over and over again.

I am currently debugging in a bare project and have also stripped my custom class to a bare skeleton as:

import UIKit
import NibDesignable

class CustomView: NibDesignable {
}

Any ideas?

lovince commented 9 years ago

Nevermind! I found the issue.

I had set the top level view in Xib as CustomView instead of a standard UIView!

lovince commented 9 years ago

Worth a highlight in the Readme.

mbogh commented 9 years ago

@lovince could you provide a sample project showcasing this? Would like to see it.

Also which Xcode version are you using?