Questions tagged [swift]

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

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

Swift: How to UI test if an attributed string is crossed out or not

I am using this method to cross out a string let attributeString: NSMutableAttributedString = NSMutableAttributedString(string: "Your Text") attributeString.addAttribute(...
0
votes
1answer
7 views

How to remove padding on left and right of list in SwiftUI

I am using a List to dynamically create multiple instances of a view, however when using list padding is added to the left and right of the child views and I can't remove it. Ive tried using ....
0
votes
0answers
5 views

How to play sequence MP3 files?

I'm trying to play sequence mp3 files by using array, for and AVQueueplayer. I see this error Expected declaration. for number in myIndex..<arr.count{ var queuePlayer: AVQueuePlayer = { ...
0
votes
0answers
8 views

How to stop rounding in NSDecimalNumber?

I am solving a question from HackerRank which asks to print the value of extra-long factorials that can't be stored even in a 64-bit long variable. I am using NSDecimalNumber to store the value. ...
0
votes
1answer
22 views

how open viewcontroller from collection view?

I am new to development in ios and I would like to know how to open a new viewcontroller from collection view. I have my collection view, now i want to open my viewcontroller color purple when image ...
0
votes
0answers
8 views

Vector pattern/tiles in a NSView

How can I draw a vector pattern/tiles from a svg inside a NSView. I have a SVG like this: and want it to display like a pattern: I know about NSColor(patternImage:NSImage) which could be applied to ...
1
vote
1answer
13 views

grab the current users first name cloud firebase swift

I have a Firebase Auth that stores the users, but it also builds a collection of users in the Cloud Firestore database. I can grab the users first name, but the problem I have is that it is always the ...
0
votes
0answers
18 views

Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value on Xcode 11 [duplicate]

i try to do play some audio files but i dont know whats wrong, i try this code but when i compile my project xcode show me thi error Thread 1: Fatal error: Unexpectedly found nil while unwrapping an ...
0
votes
0answers
11 views

NSAttributedString on UITableviewcell performance issue in swift?

I want to convert the HTML data to string. I am loading different dynamic components from the server response. I need to check each component of the data response whether it's having any html tags, if ...
1
vote
1answer
22 views

Error decoding JSON. typeMismatch(Swift.Array<Any>, Swift.DecodingError

I had a problem with JSON decoding. I understand why the error occurs, but I don’t understand how to fix it. Most likely the error is in extra square brackets somewhere in the model. Model obtained ...
1
vote
2answers
18 views

Read specific data from a Firebase Realtime Database

I've created a Firebase Database where I store users registered to my app. Database structure is My code retrieves all users saved to my database override func viewDidLoad() { super.viewDidLoad()...
1
vote
0answers
13 views

List covers custom view in SwiftUI

I am currently having a issue with SwiftUI when I put "Grid" (Github URL) in to a list, it gets covered by the next cell. But when I expand the "Text" the cell becomes larger. List(0 ..< ...
1
vote
1answer
17 views

How can I throw and handle error based on data in Swift?

Code : enum PwdError : Error { case obvious; } func chkPwd(_ pwd : String) throws -> Bool { if(pwd == "pwd") { throw PwdError.obvious; } return true; } print(chkPwd("pwd")); The ...
0
votes
0answers
7 views

Making CAReplicator display horizontally

I was wondering if there was a way to take the CAReplicator, which in my use case creates two camera previews stacked on top of one another, and instead render these two horizontally. My ...
0
votes
0answers
8 views

Interpreting IOS local-notification-actions when the app isn't running? [duplicate]

In short, I schedule a local notification to the user, which they can reply to with text. If the app is running (in either the foreground or the background), then userNotificationCenter(_:didReceive:...
-2
votes
1answer
19 views

Is there a function or method Array.reduce in swift?

I would like to reduce the array of strings into a single string using the built in array.reduce closure method. I know using the join method is easier. Just wanted to see if there is a way?
0
votes
0answers
11 views

Silhouettes of UI elements remain when they are moved within a transparent NSView

I have a semi-transparent (alpha = 0.4) NSView, which contains other NSViews. Those sub-views use mouseDown and mouseDragged to change their positions (by setting new frames) when they are clicked-and-...
0
votes
0answers
18 views

Can Collapse DatePicker

i have DatePicker https://i.ibb.co/q0GMVZn/Screen-Shot-2019-10-20-at-4-36-24-AM.png and i want Collapse to 3 line like this https://i.ibb.co/3FsD0LS/Screen-Shot-2019-10-20-at-4-36-24-AM-2.png Is ...
0
votes
0answers
10 views

Swift function from external library not importing

I am trying to create an external swift library full of functions I can call in other projects. I followed the basic steps to creating a library in Swift I ran swift package init my package.swift ...
0
votes
1answer
23 views

Custom top left and top right corner of a tableview header

I want to add round corners to top left and top right corner of a tableview header programmatically.
-1
votes
0answers
10 views

Crash on raising the keyboard on 13.1

I have the following code for when you click on a UITextView it will raise when the keyboard is shown. This is code in my ViewDidLoad() NotificationCenter.default.addObserver(self, selector: #...
0
votes
0answers
16 views

How to give action to left navigation button using swift [duplicate]

Calling setupNavigationBar() function in viewdidload(), The left bar button has camera image and given action. Doesn't seems to work. Anything wrong I am doing? func setupNavigationBar() { var ...
0
votes
1answer
27 views

Issue with value types and init’s

I’m following an old tutorial on setting up a data structure to view RGBA values in an image. For the most part of gotten past all of the out of data stuff, but I’ve run into an issue that seems ...
0
votes
1answer
18 views

Is there a way to only activate the cancel button on a search bar while editing?

I know you can do this with the clear button on a text field like this: self.searchController?.searchBar.searchTextField.clearButtonMode = .whileEditing But is there something similar for the cancel ...
0
votes
0answers
20 views

round bottomRight with byRoundingCorners not work

I'm trying to make round corner for topLeft and rightBottom, the top round work well but leftBottom still rectangle, I searched a lot I think it's overlap issue but don't know how to fix it, please ...
0
votes
1answer
18 views

iOS 13: NavigationBar BarStyle is ignored when using UINavigationBarAppearance

I have a custom colour Navigation Bar and I need to make sure the Status Bar colour is set to white. In pre iOS 13 this was easy to do, here is a code snippet from a UIViewController that did the job ...
1
vote
0answers
9 views

SKPhysicsContactDelegate, collisions not working how I want

I want to know how to get the contact delegate working. I do have contact being made, but I would like the individual bricks to disappear whenever they get hit by the ball. I've been hitting a brick ...
0
votes
0answers
15 views

iOS13: PopoverPresentationController - the border on the arrow side is missing

enter image description hereIn the same theme as this post: ios13 UIPopoverViewController showing UITableViewController - Safe Area problems / Missing parts of table But in my case, it is not ...
0
votes
0answers
6 views

MKMapSnapshotter return a black background image iOS 13

Since iSO 13, this code return a black image. Any idea? I also get these warnings logged: InfoLog FlyoverNightShader: WARNING: 0:29: Overflow in implicit constant conversion, minimum range for ...
0
votes
0answers
16 views

Overlap view over child UIViewController

I'm adding a UIView inside a child UIViewController, and I want add a little bit scale to UIView that overlap the child UIViewController but I doesn't work, I tried with self.view.bringSubview(toFront:...
1
vote
1answer
23 views

How to configure ContextMenu buttons for delete and disabled in SwiftUI?

I tried to configure the button in the contextMenu, but it's not working. Text("A label that have context menu") .contextMenu { Button(action: { // remove it }) { ...
0
votes
1answer
28 views

Update property on model if value exists in another model

I have 2 arrays of 'launchers'. A launcher is basically modelled as follows struct Launcher { let id: UUID let title: String } My API returns an array of these launchers [Launcher] and I call 2 ...
-1
votes
1answer
24 views

userDefault value is not updated until the closing the app

I have a problem with userDefault, @Sh_Khan helped me on that but I couldn't fix the problem yet, so I ask it here with more details. I created a userDefault to store a username let user_name = ...
0
votes
2answers
35 views

Argument of '#selector' does not refer to an '@objc' method, property, or initializer in Swift button target

i want to send parameter to my details func with selector but it does not work, how can i do this? btnDetails.addTarget(self, action:#selector(goToDetailsFromMap(mid:id)), for: .touchUpInside)
0
votes
0answers
10 views

Tap Push Notifications : can't be directed to specific ViewController

I'm working on app that includes a messenger feature ,the problem is every time i tap on the push notification im directed to the app itself rather than the message itself, i believe the code is ...
0
votes
1answer
15 views

How to reset the UIPickerview selectRow to default zero row

I have an application with UIPickerview with 2 components, taking the data from 2 arrays. I have set the second component on row 3 when the row 1 in component 0 is selected. That was fine, but my ...
1
vote
0answers
16 views

UICollectionView does not adapt correctly on iPad rotate

I am trying to make an adaptive layout using a UICollectionView On an iPhone I would like my view to stack, on an iPad I would like it to arrange 3 in a row. This is working, however when I rotate ...
0
votes
0answers
8 views

Access iOS microphone raw audio frames using Nativescript (javascript)

I need to check the noise dB level in a nativescipt iOS app. I can't use the nativescript-audio plugin, which uses iOS's AVAudioRecorder because it filters voice and doesn't deliver raw audio frames. ...
0
votes
0answers
15 views

Adding a menu bar extra on macOS

I am trying to create an application that will display a menu bar extra on macOS. I used a lot of code I've found on the web so far, but, while all of them compile, none actually display the menu. ...
-1
votes
1answer
24 views

Pass data to two view controllers in the two tabbars

I have a login page that get a username from user this login page is connected to a UITabbarController which contain for tabs (viewControllers). After tapping on login button, I pass the username to ...
0
votes
1answer
13 views

How to Segue from different Collection View Cells to different View Controllers

Beginner here so please forgive me. I am developing a simple fixtures app. I have set up a collection view, I am trying to make it so when I click on a cell in the collection view it takes me to the ...
0
votes
0answers
10 views

Google Maps iOS: Move camera to show all markers present inside a cluster

When didTap cluster function is called, it zooms the camera to one of the markers present inside the cluster but I want to show all the markers that were in that cluster and focus the camera on those ...
-1
votes
0answers
10 views

Alamofire - The network connection was lost only in iOS 13.1.3

I am getting following error if I am using Alamofire in iOS 13.1.3 real device. However, it works in iOS 12.4 real device. I am using Alamofire 4.5. By the way, this API call is executing when user ...
0
votes
2answers
36 views

How to make system font “Black Italic” in swift?

I am trying to add a system font of weight "Heavy" (not bold) and also try to make it italic. I saw other stackoverflow solutions but it does not seem to work. Here is what I have done: let ...
-1
votes
1answer
23 views

Vapor 3 - How to check for similar email before saving object

I would like to create a route to let users update their data (e.g. changing their email or their username). To make sure a user cannot use the same username as another user, I would like to check if ...
-5
votes
0answers
35 views

How do you convert a String to a UIImageView in swift? [on hold]

I have multiple Image Views and I want to be able to center a Button on any one of them. @IBOutlet var Button: UIButton! @IBOutlet var Image1: UIImageView! @IBOutlet var Image2: ...
0
votes
1answer
31 views

How to decode data of an array that is save and read from userDeafults - Swift

I am working on a project that it has a plist contains of rows of dictionaries , and then , I put all the rows of datas to an array and I save it to the useDefaults and all these things seems correct ,...
0
votes
0answers
7 views

Ios and Android not picking the User certificate deployed using MDM

Ios and Android not picking the User certificate deployed using MDM I've tried using Broker based auth documented below which is not working well. https://docs.microsoft.com/en-us/azure/active-...
0
votes
0answers
22 views

Swift iOS Charts - Hide certain Bar Chart value labels

I am using the 'Charts' framework for my iOS app using swift and I am using the Bar Chart on one of my VCs but it looks quite messy at the moment because it displays the value labels for every value, ...
-3
votes
1answer
26 views

My segue is not executed after taking a pic

I'm developing an app which uses a camera and then the photo is supposed to be sent to another ViewController, but i'm not sure if it maybe the segue is not be able to there or that it is just be ...