iOhYes Retired


A podcast by iOS developers for iOS developers, delivering news, tips, and rants for professional iOS/Mac developers, with something for enterprise and indie developers alike.

Hosted by Darryl Thomas and John Sextro.

← Previous Episode   |   Next Episode →

64: Properties, Properties, Properties

April 15, 2015 at 11:00AM • 57 minutes • Wiki Entry

This week we pickup where we left off with our deep dive into swift. We identify a few corrections that you helped us with and then we dive deep into properties.

We follow that up with a discussion of Methods, Self and Visibility

Show Notes & Links Presented by CacheFly

Tweet Shoutouts

The Discussion

  • Swift
    • Follow-up/Corrections
      • Implements modifying the width of a frame in Swift and Objective-C. Disassembly shows that setFrame: is called and aside from memory management and memsetting, the code is very similar.
      • “view.frame.size.width = ...” behavior
    • Properties
      • structs and classes can have them
      • stored properties
      • computed properties
        • must always be declared with var, even read-only properties
        • implemented using get/set keywords followed by closures (or at least closure-like code blocks)
        • Supports a shorthand setter declaration, in which an implied newValue value is used
      • “type-properties” like static vars
        • class type-properties are computed-only
      • property observers
        • called in response to changes in a property’s value
          • willSet (custom parameter name can provide the pending new value
          • didSet
        • called every time a property’s value is set, even if the new value is equal to the current value
    • Methods
      • Newly available to enums and structs via Swift
      • Instance methods
      • Type methods
        • class keyword in classes
        • static keyword in structs and enums
      • self
      • mutating for structs and enums
    • Visibility




Alternative show title suggestions

  • We don’t even have any show titles yet.
  • A total shot in the dark.
  • Homework’s back on