Adding an Objective-C Class
Now that you have interoperated from Objective-C to Swift, your next task is to interoperate from Swift to Objective-C. You will create a new Objective-C class to make a default image for new contacts. Your Swift class NewContactViewController will use this new Objective-C class. This simulates a fairly common reality: an existing Mac or iOS project will often have a number of Objective-C classes that are needed in the Swift components of the project.
Create a new Objective-C file that is a Cocoa Touch Class and call it DefaultImage. Its job will be to create a new contact’s default image. Make this new class a subclass of NSObject. Be sure to select Objective-C as the language for this class.
Before ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access