Wrapping an OO API in a Functional Way
summary
Shows how Swift gives structs with value semantics over existing Cocoa NS(Mutable)Data by wrapping NSMutableData in a Swift struct that exposes a bytes array and a mutating append. Demonstrates unsafe C byte access, initializer and mutating methods constrained by let/var, and the performance fix: put the ObjC object in a Swift Box wrapper + isUniquelyReferencedNonObjC check so copy-on-write avoids N copies during repeated appends (one real copy only).
AI-written summary · about
chapters (23)
- 0:00Intro
- 1:55Eric Meyer
- 3:24My story
- 7:17Burnout
- 8:13ObjectiveC Denio
- 10:05ObjectOriented Programming
- 10:36ObjectiveC Code
- 11:54ObjectiveC vs Cocoa
- 14:10Cocoa Protocols
- 15:42Swift
- 17:38Functional Programming a Swift
- 19:10Demo Time
- 19:55structs
- 25:28Creating a struct
- 27:22Variables are immutable
- 28:32Copyonwrite
- 29:26Initializer
- 30:20Reference Types
- 33:08Making Data
- 34:04Printing Data
- 34:41Making a Copy
- 42:14The Mistake
- 43:49Efficiency
related talks
19mObject-Oriented Programming in Functional Programming in Swift
28mUsability Meets Performance in Swift
18mHigh-performance systems in Swift
34mSwift: New Paradigms for iOS Development
05mThe Safety of Unsafe Swift
34mSo You Think You Know Swift?
19mUsing C, C++ and Objective C frameworks in Swift apps
26mEffective Core Data with Swift
