protocol WZProcessorDelegate {
func processorDidFinish(processor: WZProcessor)
}
class WZProcessor {
var delegate: WZProcessorDelegate?
}
⚠
Slide 29
Slide 29 text
protocol WZProcessorDelegate: class {
func processorDidFinish(processor: WZProcessor)
}
class WZProcessor {
weak var delegate: WZProcessorDelegate?
}
Slide 30
Slide 30 text
protocol WZProcessorDelegate: class {
func processorDidFinish(processor: WZProcessor)
}
class WZProcessor {
weak var delegate: WZProcessorDelegate?
}
Slide 31
Slide 31 text
@objc
Slide 32
Slide 32 text
@objc
• Expose Swift API to Objective-C
• Make concrete Swift interfaces for
Objective-C
• Access the Objective-C runtime from Swift
Slide 33
Slide 33 text
class WZManager {
init(identifier: WZIdentifier) {
// ...
}
func register(observer: WZObservable) {
// ...
}
}
Exposing API
Slide 34
Slide 34 text
@objc class WZManager {
@objc init(identifier: WZIdentifier) {
// ...
}
@objc func register(observer: WZObservable) {
// ...
}
}
Exposing API
All types involved need to be
representable in Objective-C
Don't use Swift if…
• You're shipping a binary framework.
• You need to interact with C++.
Slide 54
Slide 54 text
Don't use Objective-C if…
• You don't like Objective-C…
Slide 55
Slide 55 text
If you need to mix the two…
• Think about your use case
• Use the tools a your disposal, see how open
source projects manage this
• Think seriously about starting with Objective-C,
then adding Swift
• Consider that Objective-C is more compatible
with Swift than Swift is with Objective-C.
• Organize your project neatly!