-
Swift is modern, type-safe, expressive, performant
-
but Objective-C remains a first-class citizen
-
Same design patterns, Cocoa APIs
-
"We do not want you to rewrite or stop improving your existing code!"
-
Should you use
unowned
orweak
for delegates? -
To expose Objective-C to Swift, use a bridging header
MyApp-Bridging-Header.h
-
To expose Swift to Objective-C, Xcode gives you a generated header
- Generated as part of build process
#import "MyApp-Swift.h"
-
In a framework target, everything in the umbrella header is exposed to Swift (no bridging header)
init(data: NSData, type: String) {
self.data = data.copy() as NSData
// copy returns an `AnyObject` so we nee`d to cast it
self.type = type
}
init(coder aDecoder: NSCoder) {
data = aDecoder.decodeObjectForKey("data") as NSData
type = aDecoder.decodeObjectForKey("type") as NSString
}
- If a framework was built with Xcode 6 and has the defined modules build setting turned on, you should use @import
- Not sure how frameworks play out with cocoapods?