IOS

From Bitpost wiki
Revision as of 13:32, 16 July 2022 by M (talk | contribs) (→‎Concepts)

Modern iOS mobile app development in mid-2022 is done in Swift 5.0 and macOS 15.

Concepts

  • @Binding: allows one "source of truth" with many references called bindings
  • @StateObject: an object owned and mutated by its parent class
  • Codable: a designation that an object can be en/decoded
  • Identifiable: a designation that an object uses predictable identification (eg via an ID)
  • Custom modifiers allow you to put all your modifiers (eg .font(.headline)) into one reusable set.

Modifiers vs Custom View

Tip: Often folks wonder when it’s better to add a custom view modifier versus just adding a new method to View, and really it comes down to one main reason: custom view modifiers can have their own stored properties, whereas extensions to View cannot.

SwiftUI vs UIKit

UIKit is OLD and BIG. You'll still need it to get to some Apple services until SwiftUI is fully fleshed out. For my JSON API driven apps, I WILL AVOID IT LIKE THE PLAGUE, and hold out for SwiftUI expansion.

Installation

macOS Environment

An actual macOS development environment is required to build, test and publish an iPhone app. I set one up on the Matcha melange VM.

Development Environment

Primarily use XCode to do pretty much everything.

  • I created my app using Apple's sample app, which mocks up a simple UI.
  • I'm following a simple example to load JSON data from API.