RSSAmplifier

Blog

Needone

Technical notes and articles migrated from Ghost, organized into iOS, Android, Unity, and Other.

needone.appRSS feed ↗125 posts

Latest posts

Bridging Legacy APIs with MainActor.assumeIsolated

Despite strict concurrency checking having been available for some time, many official Apple APIs remain inadequately adapted—a situation likely to persist for the foreseeable futu

Default Actor Isolation: A Great Intention with New Challenges

While the primary goal of Swift’s strict concurrency checking is noble, it has introduced significant friction in single-threaded scenarios. Developers often find themselves clutte

Which `Context` Should You Use in Android?

Which Context Should You Use in Android? Context is everywhere in Android, but choosing the wrong one can lead to memory leaks, broken UI, or hard‑to‑debug crashes. This article ex

🚀 Swift 6 Concurrency: Mastering @isolated(any) and #isolation

Swift 6 introduces a suite of powerful new concurrency features and keywords. While many of these may not see daily use, encountering specific edge cases without a solid grasp of t

Xcode 26.3 + Claude Agent: Model Swapping, MCP, Skills, and Adaptive Configuration

Surprisely, Xcode 26.3 now features out-of-the-box support for Claude Code/Codex. Finally, developers can elegantly leverage native AI Agents directly within the Xcode environment.

How to Use SwiftUI and UIKit Together

SwiftUI is the modern way to build interfaces on Apple platforms, but most production apps still rely on UIKit. The good news is that you do not need a full rewrite. Apple designed

Kotlin `lazy` vs `lateinit`: When to Use Each

Kotlin lazy vs lateinit : When to Use Each Kotlin gives you two common ways to defer initialization of a property: lazy and lateinit . They look similar on the surface, but they so

Install specific iOS beta on simulator

Apple release the new iOS SDK every day, as the developer, we want to test our apps on those new SDK before they are officially released. For example, we want to have the iOS 17 be

How to do a deep cleaning for pod

If you are like me, the project is still using the pod to manage the libraries and frameworks. We need to clean the projects from time to time. The following command can help us to

Nested class in Swift

A nested class in Swift is a class that is defined within another class. Some key features: Nested class have access to local variables or constants of the outer class unless these

2 hours to master RxSwift - Part 2

In this article we will dig a bit more depth in some core concepts on 2 hours to master RxSwift - Part 1 . Section 1: Observable Like mentioned in the last article, an Observable i

2 hours to master RxSwift - Part 3

Introduction In the previous post: 2 hours to master RxSwift - Part 1 (needone.app) and 2 hours to master RxSwift - Part 2 (needone.app) , we get to know the the core concept behin

2 hours to master RxSwift - Part 1

a simple introudction on rxswift, including what is rxswift, how to use it and a quick example (with swift code) on demo that.

Singleton in Kotlin

In the Kotlin programming language, a singleton is a design pattern that allows you to create only one instance of a class. This is useful when you want to make sure that there is

Use keystore to store your sensitive in Kotlin

The keystore is a secure storage location in Android that is used to store encryption keys, digital certificates, and other sensitive information. The keystore is encrypted with a

Generic Type vs Any in Swift: Which One Should You Use?

Learn the difference between Swift generics and Any, including type safety, type casting, and when each approach makes sense in real code.

indirect enum in Swift

An indirect enum in Swift is an enum that can be used to define a recursive data structure. This means that one or more of its cases can refer to an instance of the same enum type.

UITraitCollection

UITraitCollection is a class in the UIKit framework that defines a set of interface traits that specify the environment in which your app is running. These traits include the devic

UIKit vs. SwiftUI - A general discussion

UIKit and SwiftUI are two different frameworks for building user interfaces on Apple platforms. UIKit UIKit is the older of the two frameworks, and has been around since the early

Certificate pinning and Public key pinning in Kotlin

With the last article ( Certificate pinning and Public key pinning ), we know the concept of Certificate pinning and Public key pinning, and how to implement them in iOS. This arti

Certificate pinning and Public key pinning

Certificate pinning and public key pinning are both techniques that are used to enhance the security of a network connection by ensuring that the client trusts only a specific cert

Download image from URL in Kotlin

In Android, we can get the image from synchronously and asynchronously, but it is more common to see in the later. Download image synchronously To download an image from a URL in K

Sort custom objects by property in Swift

Many of us have met the situation that we have an array/list of custom objects, and we want them can be sorted in a specific order. For example, we are have a group of people, and

RunBlocking in Kotlin Coroutine

In previous post, we have gone through most of the key concepts and methods in Coroutine: Kotlin Coroutines Table Content 1, Introduction to Coroutine in Kotlin 2, Non-blocking in

Format currency in Swift

Recently I have done quite an amount of work on formatting currency in Swift project, here are some tricks on how to format number in Swift: Format currency with auto currency symb

Lazy in Kotlin

In the Kotlin programming language, the term "lazy" typically refers to a type of property or variable that is only initialized when it is first accessed, rather than when the cont

Get the current week in Swift

To get the current week in Swift 5, you can use the Calendar and DateComponents classes to calculate the week number for the current date. Here's an example of how you might do thi

SceneDelegate

In iOS, the SceneDelegate is a class that is responsible for managing the scenes in your app. A scene is a discrete unit of your app's user interface, such as a window or tab. The

Data Racing in Swift

A data race in Swift occurs when two or more threads access the same memory location simultaneously and at least one of them is writing to it, without proper synchronization. This

Encode URL in Kotlin

In Kotlin, you can use the URLEncoder class to encode a URL string so that it can be safely transmitted over the internet. The URLEncoder class is part of the Java standard library

@AppStorage vs. @UserDefault in SwiftUI

Both the @AppStorage and @UserDefault property wrappers in SwiftUI allow you to store and retrieve data using UserDefaults. However, there are a few key differences between the two

HTTP Encoding

HTTP encoding, also known as percent-encoding or URL encoding, is a way of encoding special characters in URLs and other HTTP data, such as headers and body content. HTTP encoding

Get location coordinates using CLLocationManager in Swift

To get the location (latitude and longitude) of a device in Swift, you can use the Core Location framework, which is an official library from Apple. Only 2 steps are required, so i

Encode URL in Swift

It is quite common to see that we can correctly set up the HTTP header, token, body and POST/GET methods in our iOS code, but we still can't get the right response. Here is an erro

Difference between activity and requireActivity() in Kotlin

activity property In the Android framework, the Activity class represents an app's UI and provides an interface for the app to interact with the system. The activity property in a

Start and Suspend a Coroutine in Kotlin

Kotlin Coroutines Table Content 1, Introduction to Coroutine in Kotlin 2, Non-blocking in Kotlin Coroutines 3, Start and Suspend a Coroutine in Kotlin (This article) With the previ

Non-blocking in Kotlin Coroutines

Kotlin Coroutines Table Content 1, Introduction to Coroutine in Kotlin 2, Non-blocking in Kotlin Coroutines (This article) 3, Start and Suspend a Coroutine in Kotlin (incoming this

Introduction to Coroutine in Kotlin

A Coroutine is a lightweight thread of execution that can be suspended and resumed later. There are already many articles or topics covering this but this post is different, it is

Nested method in Swift

A nested method in Swift is a method or function that is defined within another function. Nested functions have the following characteristics: They have access to all variables and

Popup alert in Swift

As mentioned in the other article: Popup Custom View in UIKit : popup mainly can be: popup an alert using UIAlertController popup action sheet using UIAlertController. For more det

How to make a custom view in Kotlin

To create a custom view in Kotlin, you can create a new subclass of View and override the onDraw method to draw the view's content. Then, you can add any additional properties or b

Popup Custom View in UIKit

In UIKit, popup mainly can be: popup an alert using UIAlertController popup action sheet using UIAlertController . For more details, check this: Present action sheet in UIKit and S

Compiler directives in Swift

This post is going to list some of the most frequently used compiler directives in Swift, compatible in Swift 3/4/5. Someone might call this preprocessor directives , but they are

Present action sheet in UIKit and SwiftUI

An action sheet is a component that displays a set of choices to the user in a modal format. UIKit In iOS, you can create an action sheet using a UIAlertController with the .action

What is keyword defer in Swift

The defer keyword in Swift is used to execute a block of code at the end of the current scope, regardless of how the scope is exited. The defer block is executed after any return s

Command pattern in Swift

Many of us have heard about the Command pattern or used them in the development, which is a behavioral design pattern in which an object is used to encapsulate all of the informati

Have you tried XCTUnwrap before?

What is XCTUnwrap and how to use it to help you effectively while you are doing the unit test? XCTUnwrap is a utility function that is used in unit tests to unwrap optional values.

PLIST file in iOS

A Property List (PLIST) file is a file format used by macOS and iOS to store serialized data. It is often used to store data such as user preferences, settings, and other informati

What is YAML file and compared with JSON

YAML (YAML Ain't Markup Language) is commonly used for configuration files, but can be used in many applications where data is being stored or transmitted. A YAML file consists of

Create Property Wrapper in Swift

What is Property Wrapper Property wrapper are a language feature that allows you to wrap a piece of code around a property in Swift world, which can help us to add additional behav