iOS App Development Book/Video Series

General Category => FAQs => Topic started by: kjmcneish on May 20, 2015, 09:27:04 PM

Title: Why am I getting the "IBOutlet property cannot have non-@objc class type" error?
Post by: kjmcneish on May 20, 2015, 09:27:04 PM
You typically get the Swift Compiler error "IBOutlet property cannot have non-@objc class type" error when your IBOutlet references a Swift class that is not a descendant of NSObject.

There are two main ways to solve this problem:

1. Change your class to be a descendant of NSObject.
2. Mark your class with @objc attribute. For example:

Code: [Select]
@objc class Calculator {
}

All the best!
Kevin McNeish
Author of Learn to Code in Swift: https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11 (https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11)