Movatterモバイル変換


[0]ホーム

URL:


Khoa Pham
Khoa Pham

Ohayo

Swift Discovery

Discover all the tech

Search for the blog

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 …

Khoa Pham
Written by

My year in review 2020

Issue#715

I remember this time last year in December 2019, I spent almost every single bit of my free time onPuma because I want a Swift friendly version of fastlane that suits my need and leverages Swift 5 features.

Here’s my review of my …

Khoa Pham
Written by

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 …

Khoa Pham
Written by

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: …

Khoa Pham
Written by

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

image

GitHub Copilot has been available asVS Code extension for a while, …

Khoa Pham
Written by

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. …

Khoa Pham
Written by

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 …

Khoa Pham
Written by

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 …

Khoa Pham
Written by

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 …

Khoa Pham
Written by

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 …

Khoa Pham
Written by

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 …

Khoa Pham
Written by

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 …

Khoa Pham
Written by

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() …

Khoa Pham
Written by

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 …

Khoa Pham
Written by

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 …

Khoa Pham
Written by

How to use memory in lowdb

Issue#974

In lowdb 7, we can useMemorySynchttps://github.com/typicode/lowdb/blob/main/src/examples/in-memory.ts

import{LowSync,MemorySync,SyncAdapter}from'../index.js'import{JSONFileSync}from'../node.js'declare …

Khoa Pham
Written by

How to detect Barcode and QR code

Issue#973

Before iOS 11, we used to useCIDetector andCIDetectorTypeQRCode to detect QR code

CIDetector

An image processor that identifies notable features, such as faces and barcodes, in a still image or video.

CIDetectorTypeQRCode

A detector …

Khoa Pham
Written by

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], …

Khoa Pham
Written by

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 …

Khoa Pham
Written by

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", …

Khoa Pham
Written by

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 …

Khoa Pham
Written by

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 …

Khoa Pham
Written by
Khoa Pham

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.
Hei

[8]ページ先頭

©2009-2025 Movatter.jp