Category "swift"

How to add gradient color to UIView using Custom Class and UIAppearnace() in swift

Hello Everyone I want to add Gradient Background Color to UIView using UIAppearnce() with CustomView Class.I am facing an error - Thread 1: " Illegal axis type,

iOS 15 Navigation Bar Transparent

My iOS app uses the storyboard for the UI and uses a custom tint for the background color of the navigation bar. I have tested my app on the Xcode 13 beta 5 and

How to programmatically export 3D mesh as USDZ using ModelIO?

Is it possible to programmatically export 3D mesh as .usdz file format using ModelIO and MetalKit frameworks? Here's a code: import ARKit import RealityKit impo

Swift: Accessing argument of closure stored as variable

I ran into some code for a location manager class and I noticed that there is a variable that holds a closure. var locationInfoCallBack: ((_ info: LocationInfor

How to add test data to PreviewProvider

I am new to iOS/Swift and to the MVVM architecture and was wondering how to send in test data to the SwiftUI Preview. (Actual data is received from the ViewMode

How to use NSKeyedUnarchiver.unarchiveObject

I have a working code but that was deprecated. The following part of the code is the line with a warning. let dict = NSKeyedUnarchiver.unarchiveObject(with: out

how to get current displaying page month in string in Fscalender in swift

I know how to get the month of current page but I want to know how to get the month of current page in string in fscalender please help me I'm new to iOS. let v

Prime numbers print from range 2...100

I have been assigned with a task to print prime numbers from a range 2...100. I've managed to get most of the prime numbers but can't figure out how to get rid

What does "Fatal error: Unexpectedly found nil while unwrapping an Optional value" mean?

My Swift program is crashing with EXC_BAD_INSTRUCTION and one of the following similar errors. What does this error mean, and how do I fix it? Fatal error:

How to make a view between Spacers always at the center in an HStack?

What I would like to achieve. regardless the width of text width at both side the button should always at the center of the HStack. HStack { Text("Fooooooo

How To decode Base64 encoded .SVG string using Swift 5.x

I want to decode a base64 encoded .svg image using Swift 5.x. Can anybody guide me on how to do it? I have encoded and decoded base64 .png before. Need help abo

How do I loop over section of audio in audiokit

How do I go about looping over a section of audio? For example, I'd like to loop from, say 7.3 seconds into a song to 10.5 seconds into it over and over indefin

CreateML MLModel works on playground UI but not in app

I'm working on a machine learning app that classifies numbers that are hand drawn. I have made a model using CreateML that supposedly has 100% accuracy (I will

SwiftUI 2.0 CoreData issues with new project - 'Cannot find type 'Item' in scope'

[EDIT] I was hoping that Apple would have fixed what is obviously a bug. The solution is to clear the cache, close and reopen Xcode.. I am on Xcode Beta and sta

Accessing AppState in AppDelegate with SwiftUI's new iOS 14 life cycle

I'm using SwiftUI's new app lifecycle coming in iOS 14. However, I'm stuck at how to access my AppState (single source of truth) object in the AppDelegate. I ne

mutation attempt of frozen io.ktor.client.request.HttpRequestPipeline@151ac8

I'm using IO Ktor: ktor client core to implement multi platform network requests, but I encountered some problems When I use the class attribute created by http

Expandable forms with UITableView?

I haave to implement 3 seperate forms, but they have headers which make the forms collapsible when clicked. When searching online I saw the expanding rows for U

Detect userEvent/pan/scroll on orthogonal sections in UICollectionViewCompositionalLayout

I am using autoScroll on an orthogonal section of the collectionView using compositional layout. I need to invalidate the autoscroll timer as soon as the user m

Refreshing auth token with Moya

I'm using Moya to communicate with my API. For many of my endpoints, I require that the user be authenticated (i.e. a bearer token is based in the Authorization

Open UIDatePicker programmatically in iOS 14

I have this normal UIDatePicker (sorry that it's not in English, please ignore that): But the problem is that it only appears when I'm pressing the Date Picker