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) ...

0
votes
0answers
19 views

Adding a gesture recogniser to a view which added on UIWindow

I added a subview on UIWindow as a toast view, now I removing it(toast view) automatically after 2 sec. But I need to add a swipe/tap gesture recognizer to remove it when user swipes/touches it. I ...
0
votes
0answers
13 views

Alamofire - How to set cache enable and time for caching response in Alamofire

I am using alamofire for making network call. I want to use response caching mechanism for particular time. How I can archive the same.
0
votes
0answers
14 views

How to create PushRow function with generic parameter type

Im having different functions for creating PushRow with different types. it includes both string type and custom defined types also. How to merge these functions to a single one which accept generic ...
0
votes
0answers
17 views

AWS Recognition to Compare Face using IOS Swift

I have an issue with my logic trying to invoke the AWS Recognition Compare Faces api using IOS Swift. There isn't any documentation for Swift, but believe I may have the request set up correctly, ...
0
votes
0answers
39 views

Access values within enum

I have an enum defined like so… enum TextFieldType { case `default` case email var regularExpression: String { get { switch self { case .email: return "[A-Z0-9a-z._%+-]+...
0
votes
1answer
30 views

UITableView.visibleCells.contains(JDHeaderTableViewCell()) always return false

When I print visible cells then it shows two type of cells, see belowpo cells ▿ 2 elements - 0 : <David.JDHeaderTableViewCell: 0x7fc6880e7a00; baseClass = UITableViewCell; frame = (0 0; 375 210); ...
-1
votes
1answer
24 views

Is there a simple way to disable the shutter sound when taking a photo?

Is there a simple way of disabling a photo in swift? I am using AVFoundation to try to take an image but with no sound (replacing the sound).
0
votes
0answers
36 views

How to fill color of arrow head with dashed line & plain line

I want to create a bezier path dashed line & plain line with the filled arrow. func addDashed_Arrow(start: CGPoint, end: CGPoint, pointerLineLength: CGFloat, arrowAngle: CGFloat) { self....
0
votes
2answers
39 views

Initialization of NSAttributedString is crashing application

Below code is crashing(not always but rarely) despite the fact that it is inside do-catch block. Fabric crashlytics states that exception is Fatal Exception: NSInternalInconsistencyException and ...
0
votes
0answers
16 views

How to sort an NSOutlineView easily by a custom property?

I need to sort an NSOutlineView in ascending/alphabetical order. My NSOutlineView is used as a tree view for my application. Example of what i want to achieve: + Files - A file.c - A file.d ...
0
votes
2answers
39 views

How to get data from server Alamofire swift with header

When I want to get data from the server using Alamofire it shows me some error I want to get data from the server using the header in my header I pass id and token. @IBAction func profile(_ sender: ...
0
votes
0answers
23 views

Error Building for Unity in Native iOS App

Iam beginner in iOS development. I would like to get help for Unity in Native iOS App sample. I went through few online course which is outdated also showing some error at the end. I would like to ...
0
votes
2answers
49 views

Subclassing UITextfield in Swift

I am currently initializing quite a few properties in my view controller, but it just feels very, very messy. I have been creating UITextField like: lazy var passwordTextField: UITextField = { ...
0
votes
2answers
18 views

Swift 4, I want to be able to edit text fields in the order specified by the tags. A lot of research to no avail. I am somewhat of a novice

Can not get the the fields to edit in the order of the tags. In this scenario I have four fields on a screen in a two columns and two rows. I want to be able to be able to edit down column 1 and ...
0
votes
0answers
30 views

Touch not detected while scrolling (UITableview) while animating cell

I have added an animation for cell. func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { if indexPath.row > lastIndexPath.row{ ...
0
votes
0answers
26 views

How should I preform collection view frame change animations?

I'm trying to animate the height of my UICollectionView using UIViewPropertyAnimator.While the collection view height animates perfectly after the animation completes, I get weird scrolling behavior ...
0
votes
1answer
41 views

Title not showing on UIButton Gradient View

I have a gradient class attached to my UIButton and the gradient shows fine. However, the title or text of the UIButton is not showing. It seems the gradient is covering the text. Heres my code: @...
0
votes
1answer
61 views

UIViewController back button not shown

RootViewController -> Tabviewcontroller -> ViewController1 -> ViewController2 In such order, back button works fine but when viewController2 pops back to viewController1, viewController1's back ...
0
votes
1answer
27 views

How to retrieve data from different DatabaseReference at same time

I have places in different cities in my real time database (firebase). Following is my database structure. But according to firebase tutorial, I tried following code to get data cityA.queryOrdered(...
0
votes
1answer
16 views

iOS: External Display AVPlayerController Dismiss Issue

I'm having the same problem as this question but I don't see where I'm going wrong. It still remains on the last frame of the video on the external display. iOS Swift App AVPlayerController dismiss ...
0
votes
0answers
11 views

Audio ducking stops when AVAssetWriter.startWriting is called

We have an app where we play some audio while ducking any sounds from other apps that might be playing (music, spotify, etc). This works most of the time and external audio is ducked properly. ...
0
votes
3answers
48 views

UITableView didSelectRowAt can't get my cell

I have a question. I have a UITableView, and four custom UITableViewCells. When I scrolled to bottom, and I also can't get my custom UITableViewCell in didSelectRowAt function. Please give me some ...
0
votes
0answers
22 views

Where can I set contentOffset to the last item in UICollectionView before the view appears?

I am scrolling multiple horizontal collectionViews to the last (Far right) item using: timelineCollectionView.scrollToMaxContentOffset(animated: false) postsCollectionView....
1
vote
0answers
23 views

How to display & move vertically labels in a UIViewController?

I'm coding a sort of listing app: the first scene is a Table View Controller with all the lists created; the second is a View Controller to create or edit an existing list. Each list has a title and ...
0
votes
0answers
7 views

“Execution was interrupted” error when tokenising by CreateML

I created a simple macOS playground to make coreML text classifier as follows: import Cocoa import CreateML let url = URL(string: "https://github.com/novinfard/profiler-sentiment-analysis/raw/master/...
0
votes
1answer
13 views

camera shutter noise sometimes does not play when taking a photo.

Sometimes when you aggressively start taking pictures in my iOS camera app it sometimes does not play the noise. Why is this? To resolve this I have inserted the following. And now I was going to ...
0
votes
0answers
20 views

Get red pixel value of CGImage swift

I have a cgimage and would like to extract all of the red pixel values. I have not gotten far with this problem yet, but have been googling for a while. func getPixelData(img: CGImage) { var ...
0
votes
1answer
20 views

Local networking using URLSession - Swift 4.2, XCode 10.1

I am trying to make an HTTP request over the local network to an IP address. However, when I call dataTask it doesn't actually make the request. Requests to the internet work fine. I also tried making ...
0
votes
0answers
23 views

How to set UIRefreshControl spinner size programatically?

I'm trying to set spinner size programatically as in code below but I can't get it to be small size. With activity indicator we have two sizes; Large and normal one. I'm using smaller one for ...
0
votes
1answer
25 views

Xcode 10.1 - Simulator crash attempting to present SKStoreProductViewController in landscape iPhone 8 Plus, iPhone XR, and iPhone XS Max

The following code loads in the simulator on iPhone 5S, iPhone 8, iPhone X, and iPhone XS, and all iPads. The code also loads on a physical 8 Plus device. The code crashes in the simulator for ...
-1
votes
2answers
37 views

How to init a struct in swift 4.2

What I want: To initialise a struct before use. But I really don't know how, even after a lot of trying and searching. Example of the struct: struct Person: Decodable { let name: String let ...
0
votes
1answer
19 views

Segueing with a reusable table view

I am working on a directory listing application. Specifically, the app I am working on is called iEngineering. It would probably be best to drive home the purpose of my question if you download or ...
2
votes
2answers
26 views

Swift: Is it a good idea to use enum's raw value to access a UIButton and a string from a constant array?

I apologize in advance, this is hard to explain. I will provide more detail if needed. This is the Constants struct that I use to reference UIButtons in a collection array and use as keys for ...
0
votes
1answer
29 views

iOS Swift Floating Action Button Moves When Changing Screens

I am having some trouble with my Floating Action Button in Swift. I am using Floaty found here: https://github.com/kciter/Floaty. So it works well on the first time I click the "Calls" screen, but ...
1
vote
0answers
12 views

How do I display a users firebase account name using JSQMessages?

I am trying to retrieve a persons user information such as, first and last name from the firebase database and have it displayed above the message bubble when a user sends a message to another user. ...
-2
votes
1answer
36 views

Why does JSONDecodable Return Nil on non-nil data? [on hold]

Whenever I parse a response from the Unsplash API, I receive nil from JSONDecodable. My model conforms to Codable and I used quicktype.io to generate the model for me. The API returns an array of ...
-1
votes
2answers
37 views

Getting this error Ambiguous use of 'text'

I have created plants entity in firebase db, I want to add another value of "plantId" for some functionality. For this I am creating an random string id and passing it to plant object to be saved in ...
-1
votes
0answers
25 views

Sprite Collisions Swift 4

I have started to make a Pacman game in Swift 4 and am struggling with collisions. I am trying to make the 'pac' sprite stop when it touches a wall but I cannot seem to do it. I have tried everything ...
0
votes
3answers
29 views

How can I set a VC as Liveview in Playgrounds?

I'm currently working on a small Playgrounds project (for macOS) and I'm trying to set my own View Controller as the Live View. The following line doesn't work. PlaygroundPage.current.liveView = ...
0
votes
0answers
10 views

AudioKit - How do you tap an AKMicrophone's data to an array of doubles?

I need to get the data from AKMicrophone in raw form so i can make a custom plot. All of the examples from AudioKit use their built in plots, but I need to use a plot I made. The input my plot is ...
0
votes
0answers
30 views

Core Data Images not persisting?

I am storing and creating posts with this function in my view controller: @objc func createPost(){ guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { ...
-2
votes
0answers
18 views

Any package that uses Apple Maps for Platform IOS in flutter? [on hold]

I m looking for any package for using native maps platform based in flutter. Apple Maps for Platform IOS, GoogleMaps for Android. I searched https://pub.dartlang.org/packages? and googled for any ...
-1
votes
1answer
36 views

JSON serializing not working for this json on swift 4?

I want to parse json in below in swift 4 but sellOrders and buyOrders are return empty. JSON: { marketName: "btc_tl", chartData: [ ], sellOrders: { 39970.00: "1.42476125", ...
3
votes
2answers
49 views

Can't change the backgroundColor of a UILabel in a Static Cell

I have a table view with static cells. In there I have selected the Style Right Detail. Now I would like to change the background colour of the Detail label on the right-hand side. Even though it's ...
-5
votes
0answers
38 views

How I can open current settings path in iOS 12? [duplicate]

How can i open current settings path in iOS 12 on Swift? Location, for example. In iOS 10-11 I can, but not iOS 12. I need open Location settings from my app. My code: let url:NSURL! = NSURL(...
-1
votes
0answers
14 views

Correct DI with storyboards with custom Bundle

I am transforming Singleton into DI. I don't have AppDelegate, because I am developing a framework and this is why I create dependencies in the first VC: var repository : Repository init() { ...
0
votes
0answers
8 views

Game Center Badge Not Removed After Game Ends

In my GKTurnBasedMatch, if a player quits the turn is then passed onto the second player. As this is only a two player game, I automatically make them win upon receiving the notification. But for ...
0
votes
0answers
24 views

Exception handling in Swift in latest version [duplicate]

Is there equivalent of Java's "finally" block in Swift exception handling. I understand we use do and catch blocks. In Java there is "finally" block that certainly gets executed irrespective of the ...
0
votes
1answer
29 views

How to animate buttons to travel out of view bounds

In my home screen I have a series of buttons that are centre-aligned: New game, how to play, continue game. When clicked I want to animate the buttons to linearly move out of the screen sideways. ...
-2
votes
2answers
33 views

UISwitch TableViewCell

I have several cells with a UISwitch as the accessory view and everything as far as data being correct is fine the I toggle them. The issue I'm having is that when I toggle one and then scroll, ...

15 30 50 per page