Reading time: 4 min

This recipe shows how to perform a GET request in the background using BGTaskScheduler and BGAppRefreshTaskRequest. For whatever reason, this has way too many gotchas:

  • You can't use Alamofire, you have to use URLSession.
  • You can use URLSessionDataTask, it has to be a URLSessionDownloadTask. Why? Beats me.
  • You can't use callbacks, you must use delegates to track request progress and completion.

Continue Reading...

Reading time: 4 min

This recipe shows how to implement infinite scrolling list in SwiftUI. The result code is a single view, that can be used just like any other List. It renders data from a collection via a ViewBuilder and triggers loading when the list is scrolled to the bottom.

Continue Reading...

Reading time: 2 min

This recipe shows how to create a simple file tree using SwiftUI expandable list. This feature is useful for representing any hierarchical data structure, allowing the user to expand and collapse branches to navigate the tree.

Continue Reading...

Reading time: 5 min

This recipe is a cheatsheet for various ToolbarItemPlacement values and combinations on iOS. This is useful because:

  1. The namings of the placement values don't necessarily clearly depict where will a ToolbarItem end up.
  2. Some values don't play well with each other. E.g, .primaryAction will hide .confirmationAction if it's placed above it, but not if placed below.
  3. Some positions change if TitleDisplayMode is .inline.

Continue Reading...

Reading time: 6 min

This recipe shows how to add a Map View using SwiftUI. It also shows how to add pins/markers/annotations to the map, allowing for mixing of different map annotation types.

Continue Reading...