Join Simon Allardice for an in-depth discussion in this video Mixing and matching, part of Comparing Swift and Objective-C.
- View Offline
- We can't always start with a totally clean slate.…It's not unusual to have some code written in Objective-C,…but want to do further development in Swift,…or perhaps even the other way around.…You can very easily use Objective-C and Swift…in the same Xcode project.…You can "Mix and Match" them, and that's the term…the Apple documentation uses for this.…Now when I say mix and match, I don't mean the situation…where we're using Apple's Objective-C classes,…like NSString or AVPlayer in a Swift project.…That just works already as we've seen.…
Mix and match is the situation where you want your own files…of Objective-C and Swift code together in the same project.…Now mix and match does require separate files for them.…You can't mix Objective-C and Swift in the same file,…but you can have Swift files and Objective-C files…in the same Xcode project.…You have classes written in both languages, this multiple…language code base and they'll all compile together into the…same target and be able to work with each other without…
Need a refresher on either language? Check out Swift Essential Training and Objective-C Essential Training.
- Exploring the interoperability of Swift and Objective-C
- Comparing language syntax
- Understanding how each language uses objects and methods
- Bridging arrays, dictionaries, and numbers
- Dealing with nil return types from Objective-C methods
- Working with NSError in Swift
- Working with Swift and Objective-C strings
- Adding Swift to an existing Objective-C project
- Inheriting between languages