Guides and Sample Code

Developer

Using Swift with Cocoa and Objective-C (Swift 3.1)

iBooks

Document Revision History

This table describes the changes to Using Swift with Cocoa and Objective-C.

Date

Notes

2017-03-27

2016-10-27

2016-09-13

  • Updated for Swift 3.0.

  • Added information about bridged value types and renamed types in the Swift Foundation overlay to the Working with Cocoa Frameworks chapter.

  • Added information about global constants annotated with the NS_STRING_ENUM and NS_EXTENSIBLE_STRING_ENUM macros and functions annotated with the CF_SWIFT_NAME macro to the Interacting with C APIs chapter.

  • Added information about the #keyPath expression to the Keys and Key Paths section.

  • Added information about the #selector expression to the Selectors section.

  • Added information about imported Objective-C classes with generic parameterization to the Lightweight Generics section.

  • Added information about Objective-C class properties to the Accessing Properties section.

  • Added information about how nullable pointers are imported as optionals to the Null Pointers section.

  • Added information about performing unsafe pointer operations to the Pointer Arithmetic section.

  • Added a note to the Enumerations section about initializing imported C enumerations with raw values.

  • Added a note to the Option Sets section with information about imported C enumerations cases that have a value of 0.

  • Added information about defining a Swift protocol that Objective-C classes can conform to in the Declaring Protocols and Declaring a Swift Protocol That Can Be Adopted by an Objective-C Class sections.

  • Added information about autorelease pool blocks and the autoreleasepool(_:) function in the Autorelease Pools section.

  • Added information about the os_log(_:dso:log:type:_:) function in the Unified Logging section.

  • Updated the Interacting with Objective-C APIs chapter with information about how Swift imports Objective-C id types as Any.

  • Updated the Hashing section with information about the AnyHashable type.

  • Updated the Pointers section with information about the UnsafeRawPointer and UnsafeMutableRawPointer types.

  • Updated the Data Type Size Calculation section with information about the MemoryLayout type.

  • Updated the Swift and Objective-C in the Same Project chapter with information about the open and fileprivate access modifiers.

2016-03-21

2015-10-20

2015-09-16

2015-02-23

  • Updated for Swift 1.2.

  • Updated the Working with Cocoa Frameworks chapter to use the as! operator and bridging semantics in Swift 1.2.

  • Fixed the UIBezierPath example to correctly create a triangle.

2014-09-15

2014-08-04

  • New document that describes various aspects of Swift 1.0 and its compatibility with the Objective-C language and Cocoa/Cocoa Touch frameworks.

  • Updated the Pointers section to reflect that UnsafePointer has been replaced with UnsafeMutablePointer, ConstUnsafePointer has been replaced with UnsafePointer, and AutoreleasingUnsafePointer has been replaced with AutoreleasingUnsafeMutablePointer.

  • Noted that types that are pointed to, like NSString **, are not bridged.

  • Added the Key-Value Observing section to the Adopting Cocoa Design Patterns chapter.

  • Added the Requiring Dynamic Dispatch section to the Interacting with Objective-C APIs chapter.

  • The @IBOutlet attribute no longer implicitly declares a property as optional and weak.

  • Noted that the compiler does not implicitly synthesize the @objc attribute for private methods and properties.

  • Updated the Pointers section to reflect that CMutablePointer and CMutableVoidPointer have been replaced with UnsafePointer, and CConstPointer and CConstVoidPointer have been replaced with ConstUnsafePointer.

  • Noted that C function pointers are now imported as CFunctionPointer.

  • Updated the Swift and Objective-C in the Same Project chapter with information about access control in mixed-language targets.

  • Changed code listings to use the new Array and Dictionary type syntax.

  • Added information about bridging between Dictionary and NSDictionary.

  • Updated the Core Data section to include directions to configure the managed object model.