Lecture 5 Objective-C Compatibility

Objective-C Compatibility


  • Virtually all of the iOS API is accessible seamlessly from Swift.
  • A few special data types are handled specially and powerfully via bridging.
  • Bridging means that you can use them interchangeably.
  • NSString is bridged to String.
  • NSArray is bridged to Array<AnyObject>.
  • NSDictionary is bridged to Dictionary<NSObject, AnyObject>.
  • Int, Float, Double, Bool are all bridged to NSNumber (but not vice-versa).
  • To get from NSNumber to these types use doubleValue, intValue, etc.
  • Int, Float, Double are bridged to the C types int, float, double.

Continue Reading…