How to test DispatchQueue in Swift
Issue #646
Sync the DispatchQueue
Pass DispatchQueue and call queue.sync to sync all async works before asserting
Use mock
Use DispatchQueueType and in mock, call the work immediately
Discover all the tech
Issue #646
Pass DispatchQueue and call queue.sync to sync all async works before asserting
Use DispatchQueueType and in mock, call the work immediately
Issue #645
npm init
npm install webpack webpack-cli --save-dev
vim webpack.config.jsIssue #644
import XCTest
extension XCTestCase {
/// Asynchronously assertion
func XCTAssertWait(
timeout: TimeInterval = 1,
_ …Issue #643
Use material icons
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">Issue #642
Specify container with flex-wrap and justify-content, and item with float: left
div.cards {
display: flex;
justify-content: center; …Issue #641
Create a new page
hexo new page mydemoRemove index.md and create index.html, you can reference external css and js in this index.html. Hexo has …
Issue #640
async function useCache(
collectionName: string,
key: string,
response: functions.Response<any>,
fetch: () => Promise …Issue #639
Never use String(format: "%.2f %%", 1.2 because each region can have different separator and placement of percent sign.
Use NumberFormatter instead
Issue #638
Use commandDefinitions in XCSourceEditorExtension.
import Foundation
import XcodeKit
class SourceEditorExtension: NSObject, …Issue #638
Use commandDefinitions in XCSourceEditorExtension.
import Foundation
import XcodeKit
class SourceEditorExtension: NSObject, …Issue #636
Normally we can just wrap NSTextField
struct SearchTextField: NSViewRepresentable {
@Binding var text: String
var hint: String
var …Issue #635
textField.delegate = selfNSTextFieldDelegate …Issue #634
public enum Weapon: String, Decodable {
case sword = "SWORD"
case gun = "GUN"
case unknown = "UNKNOWN" …Issue #633
Use autoclosure and AnyView
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
public extension View {
func applyIf<T: View>(_ …Issue #632
Use Group
private func makeHeader() -> some View {
Group {
if showsSearch {
SearchView(
onSearch: …Issue #631
When your app moves to the background, the system …
Issue #630
For SwiftUI app using NSPopover, to show context popover menu, we can ask for windows array, get the _NSPopoverWindow and calculate the position. Note that origin of macOS screen is bottom left
Issue #629
Use Picker with SegmentedPickerStyle.
Picker(selection: $preferenceManager.preference.display, label: EmptyView()) {
Image("grid") …Issue #628
extension XCUIElementQuery: Sequence {
public typealias Iterator = AnyIterator<XCUIElement>
public func makeIterator() -> …Issue #627
Algorithm from https://www.w3.org/WAI/ER/WD-AERT/#color-contrast
extension NSColor {
var isLight: Bool {
guard
let …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.