Log inSign up
Point-Free
8,986 posts
Point-Free profile banner
@pointfreeco

Point-Free

@pointfreeco
A video series exploring advanced topics in the Swift programming language.
Brooklyn, NY
pointfree.co
Joined August 2017
3
Following
16.6K
Followers
RepliesRepliesRepostsRepostsMediaMediaArticlesArticles

Log in or sign up for X

See what’s happening and join the conversation

Continue with phone
or
Log in with username or email
Terms·Privacy·Cookies·Accessibility·Ads Info·© 2026 X Corp.
  • Pinned
    @pointfreeco
    Point-Free
    @pointfreeco
    Aug 24
    WWDC26 brought the new @‌State macro to succeed the property wrapper, but what’s different about the macro, and how does it work? We’ll pick apart the cryptic macro expansions to see something quite simple at its core. pointfree.co/episodes/ep378…
    Image
    00:00
    1
  • @pointfreeco
    Point-Free
    @pointfreeco
    Sep 4
    Last month we shipped 40 releases across 16 of our open source libraries, including new JSON and DB collation tools, preview traits in Dependencies, and the completion of a years-long package rename. Here’s a recap of everything that happened.
    Image
    Last Month in Point-Free: August
    From pointfree.co
  • @pointfreeco
    Point-Free
    @pointfreeco
    Sep 3
    We wrapped up our Swift isolation series a few weeks back, but our members have had some nice things to share since then... 😊 pointfree.co/collections/be…
    Image
    Image
    Image
    1
  • @pointfreeco
    Point-Free
    @pointfreeco
    Sep 2
    Compare to SwiftUI’s LazyState (wrapped in a macro by us), where we get to drop all the Optional dancing, potentially buggy “onAppear” logic, and generally write things as succinctly as possible:
    The following code snippet:

struct TripMap: View {
  @Binding var selection: Trip?
  @LazyState private var mapController: MapCameraController
  @State private var mapSelection: MapSelection<Trip>?

  init(
    selection: Binding<Trip?>,
    modelContext: ModelContext
  ) {
    self._selection = selection
    self._mapController = LazyState {
      MapCameraController(modelContext: modelContext)
    }
  }

  var body: some View {
    Map(position: $mapController.cameraPosition, selection: $mapSelection) {
      ForEach(mapController.trips) { (trip: Trip) in
        if let location = trip.location {
          Marker(trip.name, coordinate: location.coordinate)
            .tint(trip.color)
            .tag(MapSelection(trip))
        }
      }
    }
    .onChange(of: mapSelection) { _, newValue in
      if case .some(let mapSel) = newValue {
        selection = mapController.trips.first { MapSelection($0) == mapSel }
      }
    }
  }
}
    @pointfreeco
    Point-Free
    @pointfreeco
    Sep 2
    Code from Apple's SampleTrips WWDC26 project (with problem areas highlighted):

struct TripMap: View {
  @Environment(\.modelContext) private var modelContext
  @Binding var selection: Trip?
  @State private var mapController: MapCameraController?
  @State private var mapSelection: MapSelection<Trip>?

  init(selection: Binding<Trip?>) {
    self._selection = selection
  }

  private var cameraPosition: Binding<MapCameraPosition> {
    Binding(
      get: { mapController?.cameraPosition ?? .automatic },
      set: { mapController?.cameraPosition = $0 }
    )
  }

  var body: some View {
    Map(position: cameraPosition, selection: $mapSelection) {
      ForEach(mapController?.trips ?? []) { (trip: Trip) in
        if let location = trip.location {
          Marker(trip.name, coordinate: location.coordinate)
            .tint(trip.color)
            .tag(MapSelection(trip))
        }
      }
    }
    .onAppear {
      self.mapController = MapCameraController(modelContext: modelContext)
    The pattern Apple has established for influencing a view’s @‌State from a parent: 1. Make the state private and Optional 2. Populate the state in onAppear This means extra boilerplate, imprecise domains, optional coalescing and chaining dances, and potential lifecycle bugs!
    2
  • @pointfreeco
    Point-Free
    @pointfreeco
    Sep 2
    The pattern Apple has established for influencing a view’s @‌State from a parent: 1. Make the state private and Optional 2. Populate the state in onAppear This means extra boilerplate, imprecise domains, optional coalescing and chaining dances, and potential lifecycle bugs!
    Code from Apple's SampleTrips WWDC26 project (with problem areas highlighted):

struct TripMap: View {
  @Environment(\.modelContext) private var modelContext
  @Binding var selection: Trip?
  @State private var mapController: MapCameraController?
  @State private var mapSelection: MapSelection<Trip>?

  init(selection: Binding<Trip?>) {
    self._selection = selection
  }

  private var cameraPosition: Binding<MapCameraPosition> {
    Binding(
      get: { mapController?.cameraPosition ?? .automatic },
      set: { mapController?.cameraPosition = $0 }
    )
  }

  var body: some View {
    Map(position: cameraPosition, selection: $mapSelection) {
      ForEach(mapController?.trips ?? []) { (trip: Trip) in
        if let location = trip.location {
          Marker(trip.name, coordinate: location.coordinate)
            .tint(trip.color)
            .tag(MapSelection(trip))
        }
      }
    }
    .onAppear {
      self.mapController = MapCameraController(modelContext: modelContext)
    4
Advertisement
Advertisement