Questions tagged [swift]

Swift is a general-purpose programming language developed by Apple Inc first released in 2014 for its platforms and Linux. Swift is open-source. Use the tag only for questions about language features, or requiring code in Swift. Use the tags [ios], [ipados], [macos], [watch-os], [tvos], [swiftui], [cocoa-touch], and [cocoa] for (language-agnostic) questions about the platforms or frameworks.

Filter by
Sorted by
Tagged with
0votes
0answers
6views

How to make signalEnumerator(for: identifier) call the relevant enumerateChanges method

In macOS FileProvider extension, when I invoke: manager.signalEnumerator(for: identifier) { error in print("Signal completed with error: \(error)") } where identifier is identifier of ...
user avatar
  • 1,527
-2votes
4answers
16views

How to get function's parameter value without parameter name in swift?

func test(_: [Int]) { print("xxx") } test([1,2,3]) I saw this code is valid in swift, how can I get the value passed in test?
user avatar
0votes
2answers
18views

Is is complusory to use "in" keyword in closure? If no then what is the difference between closure and computed property in swift?

In swift use of get and set is not compulsory and if use of "in" in closure is also not compulsory then how to differentiate a closure and computed property? Like in below example greet is a ...
user avatar
-1votes
0answers
7views

What is the equivalent of Swift Package in Kotlin?

I am totaly new to Kotlin but I got 1 project of building an SDK in Kotlin that the Kotlin SDK API can be call from other Kotlin projects. After some days of investigation, I use IntelliJ IDEA CE as ...
user avatar
-1votes
1answer
13views

Swift MacOS know the version of the OS and Xcode

I should print for a program on macOS, the Xcode and OS version. Eg: OS: macOS 12.3 Xcode: 13.3 How can I do? Edit: Maybe for the mac version I did it: let osVersion = ProcessInfo.processInfo....
user avatar
  • 2,290
0votes
1answer
14views

Create date by components in swift

Hello i have a problem: I try to create date by components but it's give me wrong hours.. For example, I want to have 2022-04-24 00:00:00 Here the code func createDate(year: Int, month: Int, day: Int,...
user avatar
-1votes
0answers
8views

Where do I add this FAN line of code in iOS Flutter?

I am reading FAN documentation for flutter project. Link: https://developers.google.com/admob/ios/mediation/facebook#swift_1 It didn't state where to put this line of code in flutter project. ...
user avatar
  • 113
0votes
0answers
18views

SwiftUI tool bar button not working in ios 14.5

I have a toolbar button that works perfectly fine by executing its function in ios 15.0 and above. However, in ios 14.5 it loses its colour and functionality altogether. Does ios 14.5 have different ...
user avatar
-1votes
0answers
10views

iOS : is it possible to send Notifications to iOS simulator from Firebase

*Hi all am trying to integrate pushnotifications with firebase I don't have real device as of now I want to test with simulator is it possible to send notifications from firebase to iOS simulator ...
user avatar
-1votes
0answers
33views

Dictionary returns all conditions in swift

Iam trying to compare values in a dictionary to a functin param func auth(userName:String,pwd:String) throws -> Bool { for(key , value ) in authDict { if( key.compare(...
user avatar
  • 404
0votes
0answers
12views

Swift -AVPlayer's PeriodicTimeObserver is Briefly Incorrect

I've been testing this for a couple of days now. This problem only occurs on a real device, not the simulator. The video loads, starts to play, (1) I pause it, (2) I play it, (3) I pause it. After the ...
user avatar
1vote
1answer
23views

Applying timezone offset data provided by OpenWeatherMap (Swift)

Getting the current day, hour, minute etc for the users current location is fairly straight forward using a function like this, so long as you have UTC data: func getHourForDate(_ date: Date?)-> ...
user avatar
  • 81
-3votes
1answer
23views

How to convert Swift Codable array and group as a Dictionary? [duplicate]

Let's say I have this code. struct Movie: Codable { var name: String? var year: String? var genre: String? } let movie1 = Movie(name: "Midsommar", year: "2019", ...
user avatar
  • 2,216
0votes
1answer
41views

Published Bool variable resetting automatically

I have the following simple SwiftUI view which contains a component containing a list of marketing preference options with checkboxes and a button to update the preferences: @StateObject var ...
user avatar
  • 773
-1votes
1answer
28views

Swift present viewController issue

I have a ViewController that I present like this: guard let vc = storyboard?.instantiateViewController(withIdentifier: "calendarViewController") as? FSCalendarViewController else {return} ...
user avatar
  • 1
0votes
0answers
14views

How can I reuse part of code (recognizer, toolbar) applied to a textview?

I have a class called ThemeVC which has a textview (connected with an IBoutlet) and functionalities applied to it (it has a recognizer that detects the tapped words). My goal here is that I would like ...
user avatar
  • 261
0votes
0answers
15views

How can I get the name of a NSmenuItem in a submenu?

I can get the name of a NSmenuItem at the top level of a NSMenu. I do this by adding an action to the NSmenu: @IBAction func menuDropdownAction(_ sender: Any) { let titleOfSelectedItem = (sender ...
user avatar
0votes
1answer
14views

SwiftUI: Filter Core Data fetch by relationship (NSPredicate)

@Environment(\.managedObjectContext) private var viewContext @FetchRequest( entity: ListStruct.entity(), sortDescriptors: [NSSortDescriptor(keyPath: \ListStruct.name, ascending: true)], ...
user avatar
2votes
1answer
25views

Set all variables in view

Question: How can I easily change all variables in separate views inside a ForEach statement? (View remarks in code.) ContentView() @State var isShowing = false var body: some View { Toggle("...
user avatar
0votes
0answers
16views

How to determine the type of error in RxSwift

How can I determine if the error in RxSwift is a 401. I use this func extension LoginInteractorApi { // MARK: - Internal func loginUser(input: LoginInputModel) -> Observable<Async<Any>...
user avatar
  • 3,267
2votes
1answer
25views

How to append elements into an array from another View Controller in Swift

Hello guys I have a question about append a new element into an array everytime i pressed a button. I have two View Controllers, the first one "RegisterViewController", that contains a ...
user avatar
0votes
1answer
26views

JSONDecoder Parsing Data but returning nil

I am making a simple get request that is returning nil. I have made other get requests to the same API with success, so I don't know if my struct is wrong. API Response: { "response": { ...
user avatar
0votes
0answers
15views

I am unable to delete a tableView Row

I have been stuck on this for some time now, I built a tableView App with the ability to delete a row. I am using with CoreData and iCloud. When I use "editActionsForRowAt" it deletes from ...
user avatar
  • 133
0votes
1answer
22views

Is there any way to find out why Preview Crashed on Xcode - SwiftUI

Sometimes my app crash, it shows - preview crashed. So I have to find the reason manually. So I'm looking for a solution If I can get the reason why my preview crashed, as we get the reason in android ...
user avatar
0votes
1answer
29views

TabView Indicator doesn't move when page changes

When I scroll from one page to the other the horizontal indicator bar doesn't move, what would be the appropriate way to move it (with animation if possible)? The green area below doesn't move to the ...
user avatar
  • 1,543
1vote
1answer
35views

What's the difference between ARSession delegate methods?

I am in the process of making a Swift app that currently places some simple shapes onto a reference image using an ARImageAnchor and an ARReferenceImage. Right now, all of the augmented content is ...
user avatar
  • 58
0votes
0answers
22views

Presenting UIViewController in UIView

I have recently started with ios development. So currently I have a requirement to present a QR scanner view when a view is clicked. I came through one library https://github.com/twostraws/CodeScanner....
user avatar
0votes
0answers
9views

Change default StackView animation

Forgive me if explanation is not excellent. Basically, the video below shows the standard animation for hiding labels in a stack view. Notice it looks like the labels "slide" and "...
user avatar
  • 1,408
0votes
0answers
11views

User interaction line ios-charts

I want to drag a circle along the line of the graph. Please look at this screenshot? I use (Charts)[https://github.com/danielgindi/Charts] v.3.6.0. I see similar case here: Interactive Tracking with ...
user avatar
  • 977
-4votes
3answers
33views

How to return struct in swift?

This is my struct: struct State { var current: StateEntry? var rStack: [StateEntry] = [] var uStack: [StateEntry] = [] } and i have a func that has return type State: func createEmptyState() -&...
user avatar
0votes
1answer
21views

How to center this model in SceneKit

Imported a tiger model into SceneKit, but it is off center? Is this something I can fix? The green/red/blue arrows should be under the model?
user avatar
  • 7,624
-1votes
0answers
22views

How to get a string representation of a function signature which is not the current function in swift

I am attempting to create a log statement that says "Not Implemented, use x function instead" I know that I can get the name of the current function by using the #function expression. How do ...
user avatar
  • 2,119
-2votes
1answer
17views

how can i make UIbutton smaller? not programatically

how can i make this button smaller? I have added constraints but it does not work.
user avatar
0votes
3answers
23views

How can I pass parameters in an HTTP Post request in Swift?

Am working on a simple Swift test app which just calls Perl script on my server. Right now I just want to send over a username and id, and get them back in a JSON response. Nothing more, am still in ...
user avatar
0votes
0answers
7views

Init `HTTPURLResponse` from file containing raw HTTP response

Does anyone know if there is a way to create an instance of NSHTTPURLResponse from a text file containing a raw HTTP response? As an example, if I type curl -D - http://google.com in to terminal, I ...
user avatar
  • 12.6k
0votes
0answers
9views

How to build Swift framework with 3rd party SPM dependencies

I've built swift frameworks before, but I've never dealt with one that has 3rd party dependencies. What I have right now is a Swift framework that has a dependency on several Swift packages. When I ...
user avatar
1vote
2answers
34views

Swift: Capture list

var array = [() -> ()]() var count = 0 var index = 0 while index < 5 { array.append { print("count: \(count)") print("index: \(index)") } count +=...
user avatar
  • 11
0votes
1answer
11views

Localization stings when differ order of numbers

I'm doing language localization of a Swift iOS app to Chinese. How can I translate a "%d of %d last weeks" which for English is "1 out of the 2 last weeks" but becomes "...
user avatar
  • 73
0votes
1answer
27views

Remove time from ISO date to filter with Vapor Swift

I'm trying to figure out how to filter ISO dates. I'd like to filter out Todo's for a specific day. Dates are save in the database like this: "started" -> 2022-03-17 18:46:44+00 I'd like ...
user avatar
0votes
1answer
15views

Why GMUClusterManager is not showing on iOS?

I try to use SwiftUI view using the UIViewRepresentable pattern, the GoogleMaps background works but the ClusterManager doesn't show anything. Is there something wrong? I try to generate 10000 markers ...
user avatar
  • 33
0votes
0answers
14views

UISplitViewController's show details does not seem to replace the detail view

I have an app where there is a UISplitViewController with a navigation controller, itself bound to a UITableViewController displaying a menu to navigate. There is no Detail View Controller being bound,...
user avatar
  • 1,737
0votes
0answers
12views

Can't use URLSession with Swift on Watchkit

I have a problem when trying to fetch some data with swift on apple watch. When i try this code in Swift Playground it works well but when I put it in an WatchOS app it shows me this error : Error ...
user avatar
  • 103
1vote
1answer
51views

Swift WKWebView Class

I am implementing a custom WKWebViewClass. The init() is settings the navigationDelegate to self, and starting the load. However, didFinish is never called. I am getting a didFailProvisionalNavigation ...
user avatar
  • 11
0votes
0answers
12views

locate xcdatamodeld file in swift package

I try to build an application for iOS and watchOS. Both projects would use the same domain model and for that purpose I would like to split my codebase into distinct platform projects and at least one ...
user avatar
0votes
1answer
27views

Swift/Xcode: Multiple Returns to Array

Having some trouble with my code. So I have these HealthKit Objects I'm trying to return to be displayed as widgets later on in my code. import Foundation struct Activity: Identifiable { var id: ...
user avatar
-3votes
0answers
17views

Medical assessment and subscriptions via a payment gateway [closed]

I am working on a health assessment application in which I am taking user inputs about specific questions, then analysing the user entered data. After that, we're tracking the user's health on a daily ...
user avatar
0votes
0answers
7views

SCNPlane between two SCNVector Scenekit

I have 2 SCNVectors startPoint and endPoint, I'm try to create a SCNplane extend between this point. I read some answer here in SO but no one can answer my doubt. I found code to draw a line between ...
user avatar
-1votes
1answer
30views

Xcode removes drop shadow from SVG assets

I have two files: view-with-shadow-pdf.pdf view-with-shadow-svg.svg They are the exact same image from Figma, only once exported as PDF and once as SVG. These are the PDF and the SVG files. When I ...
user avatar
0votes
0answers
33views

How to get exact data from JSON and also have online access to it [closed]

I try to make kind of shopping app and try to find a solution. I have an API currencylayer and I need to get from there a conversion from USDEUR and USDCZK and apply it when user will choose another ...
user avatar
0votes
1answer
23views

View resized even after setting contentHuggingPriority to defaultHigh

I have a vertical stackView. bodyStackView.translatesAutoresizingMaskIntoConstraints = false bodyStackView.axis = .vertical bodyStackView.alignment = .fill bodyStackView.distribution = .fill ...
user avatar
  • 132

15 30 50 per page
1
2 3 4 5
6220