Featured
How to use playground in Swift file
Issue#998
Traditionally, if we wanted to quickly test a function or a piece of logic, we would open a separate Playground file (.playground
).
From Xcode 26 we can have access to the new#Playground
macro in Swift 6.2. This allows us to declare a …
How to morph liquid glass view transition
Issue#997
An interesting feature in iOS 26 is the ability to create morph “Liquid Glass” effects, where views with the.glassEffect()
modifier can fluidly morph into one another. This is achieved usingGlassEffectContainer and the …
How to prompt users to configure widgets in iOS 18
Issue#996
When creating widgets for iOS, especially those that need user input to be useful, one common challenge is guiding the user to configure them. Before iOS 18, a user would add a widget, but then would have to know to long-press it and …
How to make zoom transition animation in iOS 18
Issue#995
With iOS 18, SwiftUI introducesmatchedTransitionSource andnavigationtransition as a powerful new way to create zoom animations between views. This allows you to smoothly transition from a small view to a larger, more detailed view, …
How to create mesh gradient in iOS 18
Issue#994
With iOS 18, Apple introduced a powerful new tool for creating beautiful, dynamic backgrounds:MeshGradient
. Forget simple two-color gradients; mesh gradients let you blend a whole grid of colors together smoothly, creating stunning, …
How to animate number change from iOS 17
Issue#993
Before iOS 17, if you wanted to animate a number changing, SwiftUI would just fade the old number out and fade the new one in. It worked, but it wasn’t very exciting.
Here’s how that looked:
structOldCounterView:View{@ …
How to observe model changes in iOS 26
Issue#992
In the past, making your screen update when data changed in UIKit meant writing extra code, either with didSet, Combine or some other callbacks. Now, it’s automatic.
With the latest iOS 26 updates, UIKit can automatically watch your …
How SwiftUI StateObject and React useState defer initial value evaluation
Issue#991
When building apps inSwiftUI orReact, we often need to store values that change — like a counter, user input, or a list of items.
To do this:
- React gives us
useState
. - SwiftUI gives us
@State
and@StateObject
.
But here’s something cool: …
How to tap again on tab bar item to scroll top in iOS
Issue#990
In many popular apps like LinkedIn, Reddit, we can tap again on a bar bar item to scroll to top. Although this behavior is not built in by iOS, we can implement that very easily.
The idea is to keep track ofprevious selection
so we can …
How to make NSImage Sendable in Swift
Issue#989
In Swift 6, Apple introduced stricter rules to help make your code safer when using concurrency (like async, await, Task, and actor). These rules check that types used in concurrent code are safe to share across threads.
Types that are …
How to observe optional ObservableObject in SwiftUI
Issue#988
When working with Core Data, there are times we have optionalNSManagedObject
to pass around. These objects conform toObservableObject
, and in SwiftUI we can’t@ObservedObject
on optionalObservableObject
One way we can workaround …
How to clear background for TextField inside list in macOS
Issue#986
When using TextField in SwiftUI List on Mac, it has unwanted background color when focused. We can turn it off using introspection or a custom TextField wrapper
TextField("Search",text:$searchText).introspect(.textField,on: …
How to use GitHub Copilot for Xcode
Issue#985
DuringGitHub Universe 2024, GitHub announced thatGitHub Copilot code completion in Xcode is available in public preview. The project is open source atCopilotForXcode
GitHub Copilot has been available asVS Code extension for a while, …
How to conditionally render widgets in iOS
Issue#984
TheWidgetBundle lets us expose multiple widgets from a single widget extension
It usesWidgetBundleBuilder to constructs a widget bundle’s body.
In iOS 18, if we includeControlWidget
then we need to checkiOSApplicationExtension iOS 18
. …
How to open app with Control Widget on iOS 18
Issue#983
In iOS 18, we can make Control Widget in Widget extension
importWidgetKitimportSwiftUI@available(iOS18.0,*)structBookControlWidget:ControlWidget{varbody:someControlWidgetConfiguration{StaticControlConfiguration …
How to use NSFetchedResultsController memory wise in Core Data
Issue#982
If you’re usingNSFetchedResultsController
in Core Data, it might take up a lot of memory, especially when working with large datasets. To keep your app running smoothly, it’s important to manage memory efficiently
Use Fetch Limits and …
How to use NSDragOperation
Issue#981
NSDragOperation represent which operations the dragging source can perform on dragging items.
There are several types of drag operations, and each one has a different purpose and visual cue.
Copy Operation.copy
- What It Does: The item …
How to make NSCollectionView with diffable data source and SwiftUI
Issue#980
NSCollectionView, available since macOS 10.5+, is a good choice to present a list of content. Let’s make a SwiftUI wrapper forNSCollectionView
with diffable data source and compositional layout
Use NSViewControllerRepresentable …
How to use React Query useQuery with debounce
Issue#979
When dealing with user input, such as in an autocomplete component, it’s common to implement debouncing to reduce the number of API calls and improve the user experience.
React Query’suseQuery
hook makes it easy to manage the …
How to handle tap gesture in SwiftUI Charts
Issue#978
From iOS 17, SwiftUI Charts haschartGesture, together withSpatialTapGesture we can check tap location and convert that to Charts value
Chart{}.chartGesture{chartinSpatialTapGesture().onEnded{valuein …
Hello, I’m Khoa
I’m a thinker and storyteller with a passion for exploring the intersection of creativity and technology
🧑💻 I love crafting high quality and useful apps🔥 I love open source. My GitHub open source has 2.3k followers with packages that are integrated by 45k+ apps and over 3.4m+ downloads on CocoaPods.✍️ I write here on my blog and on Medium, which has over 2.7k+ followers with tons of articles and 90k+ monthly views.🖥 Follow me for sharings about Swift, SwiftUI, iOS and macOS development.