0

I been trying to get to get up to speed with swift, and it not going very well for the moment.

I tried to make a custom UIview on a nib that basically has 2 labels to show date and month very simple. I set up the xib file attached the outlets set my file's owner to the custom class. same I do in objective-c.

I set up the init with coder and when I try and use the UINib to get the nib and set up my UI I get this crash.

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key centerDot.'

this is the faulty code (project URL below on github)

class func instanceFromNib() -> UIView {
        return UINib(nibName: "ACDateView", bundle: nil).instantiateWithOwner(self, options: nil)[0] as UIView
    }

required init(coder aDecoder: NSCoder) {
    date = NSDate()
    frameInset = UIEdgeInsetsZero
    itemDistance = 0
    direction = 0

    self.view = ACDateView.instanceFromNib()

    super.init(coder: aDecoder)
    addSubview(view)
}

https://github.com/nissaba/TowLineDate

Also at the same time I was trying this live rendering that we can do now in xcode6 but that fails also saying that

file:///.../Base.lproj/Main.storyboard: error: IB Designables: Failed to update auto layout status: dlopen(ACDateView.framework, 1): no suitable image found. Did find: ACDateView.framework: mach-o, but wrong architecture

So I am guessing from my reading that I may be wrong to use the framework as I saw in some example on the net, or its just some thing. I tried with out the frame work I did get the same message.

Pascale Beaulac
  • 889
  • 10
  • 28
  • I Learned that the files owner needs to be NSObject and that its the view that needs to be set tot he object. But I am still getting errors. `2014-10-11 23:40:35.717 TwoLineDate[789:106394] Failed to set (text) user defined inspected property on (UIView): [ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key text.` – Pascale Beaulac Oct 12 '14 at 03:46
  • Found this tutorial: http://www.weheartswift.com/make-awesome-ui-components-ios-8-using-swift-xcode-6/ pretty much fixed my project. – Pascale Beaulac Oct 12 '14 at 05:02

0 Answers0