Featured
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 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 …
How to sign in with Apple and Firebase and Supabase
Issue#977
ShowASAuthorizationController
with a simple nonce. Once we have theidToken
, create anOAuthProvider.appleCredential
and pass toFirebase Auth
finalclassAppleLoginService:NSObject{staticletshared=AppleLoginService() …
How to serve a local development environment over https using pnpm and webpack
Issue#976
When developing locally, especially when interacting with third-party services that have CORS restrictions, serving your development environment over a custom domain with HTTPS can be crucial. Let’s walk through the steps to achieve this …
How to use React Custom Hooks as the View Model pattern
Issue#975
When building a React application, separating the logic and state management from the UI can make your code easier to manage, test, and reuse. This is where the view model pattern comes in handy. By using a custom hook as a view model, you …
How to use memory in lowdb
Issue#974
In lowdb 7, we can useMemorySync
https://github.com/typicode/lowdb/blob/main/src/examples/in-memory.ts
import{LowSync,MemorySync,SyncAdapter}from'../index.js'import{JSONFileSync}from'../node.js'declare …
How to detect Barcode and QR code
Issue#973
Before iOS 11, we used to useCIDetector
andCIDetectorTypeQRCode
to detect QR code
An image processor that identifies notable features, such as faces and barcodes, in a still image or video.
A detector …
How to make swifty UserDefaults
Issue#972
We want to have a swifty UserDefaults API that works with subscript and in a type safe manner.
extensionDefaults.Keys{staticletstring=Defaults.Key("string",default:"0")}XCTAssertEqual(defaults[.string], …
How to use act vs waitFor using React Testing Library
Issue#971
When testing React components, dealing with tasks that happen at different times is super important to make sure your tests give reliable results.React Testing Library gives you two important tools for dealing with these situations: act …
How to use OSLog and OSLogStore in Swift
Issue#970
We can useLogger
to log andOSLogStore
to retrieve logs
importOSLogimportReuseAcrossfinalclassLogService{staticletshared=LogService()letlogger=Logger(subsystem:"com.example.myapp", …
How to include custom error payload in hapi Boom
Issue#969
Hapi.js, commonly referred to as Hapi, is an open-source, back-end web application framework for building and deploying web applications and APIs in Node.js
In Hapi.js, you can use the Boom module to create and return error responses in a …
How to read image paste from clipboard in React
Issue#968
Are you looking to grab images directly from your clipboard with a button click on your web page? The Async Clipboard API makes this quite easy and efficient. Let’s break it down into simpler steps:
Requesting Permission
The first …
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.