Skip to content

Instantly share code, notes, and snippets.

Integrating Swift With Objective-C

Introduction

  • 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 or weak for delegates?

  • To expose Objective-C to Swift, use a bridging header

WWDC 2014

Extending Swift

Making something anonymous

for (key, _) in dictionary {
	println(key)
}
@0thernet
0thernet / WWDC2014_IntroToLLDBAndTheSwiftREPL.md
Created June 6, 2014 23:45
WWDC2014_IntroToLLDBAndTheSwiftREPL

Intro To LLDB and the Swift REPL

Sean Callanan

Basic debugging

  • lldb commands
    • ti/ thread info
      • EXC_BAD_INSTRUCTION = CPU doesn't understand an instruction
        • typically used in assertions -> Assertion failure
    • bt / thread backtrace
  • prints all frames on the stack of the current thread

Working with Cocoa

Implicitly Unwrapped Optionals

  • A value of class type in Swift is never nil
    • var fileModificationDate: NSDate!
  • Objective-C does not have a notion of a "never-nil" pointer
  • ! is an implicitly unwrapped optional
    • can be tested explicitly for nil
    • can directly access properties/methods of the underlying value
    • can be implicitly converted to its underlying value

WWDC 2014 Brain Lanier

Optionals

  • Cleaner alternative to using sentinels (NULL, NSNotFound, etc.) to represent invalid values
  • optionals are initialized to nil by default
    • var optionalNumber: Int?
  • nil is a sentinel value that works with any type
  • value is wrapped in optional by setter
    • optionalNumber = 6

New iTunes Connect

Analytics

Metrics

  • app store views
  • installs
  • sessions
  • active devices
  • retention
  • stickiness
@0thernet
0thernet / README.md
Last active July 3, 2023 14:07
Force Editor + Pan/Zoom

Drag from an existing node to add a new node or link. Click to select/deselect nodes/links. Hit the DELETE key to remove the selected node or link. Drag to pan. Scroll to zoom.

Built with D3.js.

@0thernet
0thernet / README.md
Last active June 30, 2022 14:33
Force Directed Graph Editor

Drag from an existing node to add a new node or link. Hit the DELETE key to remove the selected node or link.

Built with D3.js.