With Swift, it's no longer necessary to inherit from NSObject. Should I still subclass from NSObject for the data model classes in my iOS app?
Asked
Active
Viewed 562 times
1 Answers
3
The main benefit of subclassing NSObject
is that when bridging to Objective-C code, the class will be bridged over. If you have a bare Swift class
, then it will not be visible via the Objective-C bridge.
You can decide whether or not you want to subclass NSObject
based on whether or not you want to maintain Objective-C compatibility.

Cezary Wojcik
- 21,745
- 6
- 36
- 36
-
3I want to add that subclassing `NSObject` implicitly adds `@objc` to your class. If you don't subclass `NSObject` and add `@objc` yourself, it will still be bridged to ObjC – Jack Jun 23 '14 at 16:29
-
-
1Also, pure swift classes cannot be the target or client of Key Value Observation, which is in my mind, the best way to interface between your model and your views. – David Berry Jun 23 '14 at 18:58