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.

-1
votes
0answers
6 views

How to access variable assigned inside API?

I'm trying to run the API function, change the variables, and then show those results in the view. I looked at other solutions on Les Vesti, but didn't understand any of them. Therefore, I ...
0
votes
0answers
11 views

Invalid update: invalid number of items in section 0

I am hitting the following error when attempting to drag items from one UICollectionView (collectionView) into another (rackView): 'NSInternalInconsistencyException', reason: 'Invalid update: invalid ...
-1
votes
0answers
4 views

Update directions label using MapKit MKDirections

I have MapKit set up to display local hospitals and emergency services. When a pin is selected my directonsLabel displays the first set of directions to the destination. However when I start driving ...
0
votes
0answers
9 views

How to prevent TableView from crashing?

I have a data model with items. Depending on the situation I only want to show X amount on the tableView. The issue is when I delete items it crashes. I am Using prefix in order to return the amount ...
-1
votes
0answers
15 views

Underscores don't display in NSTextfield

I want to display underscores in my NSTextfield, but they are converted to spaces. Is there a way to make them show up?
0
votes
2answers
24 views

Super simple trailing closure syntax in Swift

I am trying to follow the example in the Swift docs for a trailing closure. This is the function: func someFunctionThatTakesAClosure(closure: () -> Void) { // function body goes here ...
0
votes
1answer
25 views

How to mock URL struct?

I am writing some code to be able to make testing easier. After researching, I found a good way of making URLSession testable is to make it conform to a protocol and use that protocol in the class I ...
-1
votes
0answers
22 views

How to make a label which cross the screen

I'm trying to create a label, which across the screen from the right to the left (tap for begin the new level). There is actually two problem : the first one is that the scrolling is not good. Indeed,...
0
votes
1answer
14 views

PromiseKit: can't call custom code between then handlers

Just started with PromiseKit and running into a weird compile problem: with firstly: Ambiguous reference to member 'firstly(execute:)' () without firstly: Unable to infer complex closure return type; ...
1
vote
1answer
20 views

Defining context for Core Data with AppDelegate as a singleton

I’m trying to get my head around NSManagedObjectContext for Core Data. Xcode 10.1 provides a fair amount of boilerplate if the Core Data checkbox is selected when creating a new project. But I find it ...
-1
votes
0answers
12 views

How to extract AAC raw data from a .CAF file?

On iOS, I'm looking to extract the raw AAC data (kAudioFileAAC_ADTSType) from a .CAF audio file which already contains the AAC data (= no format conversion). I found this post saying it is possible ...
0
votes
0answers
6 views

How to add effect to the output video? Swift 3

My problem is about adding blur filter while recording a video and save it to a temp url. I did a lot of searches on the internet and all I found is about creating CIFilter and added to UIImage My ...
1
vote
1answer
14 views

how to display global dictionary items in table view

There are two views in my project: in the first one users input two words and those words are saved in a dictionary as the key and the value. The code in short: var words = [Dictionary<String, ...
0
votes
1answer
9 views

Is there a way to quit browser session in Swift or RxAlamofire?

I am web scrapping a specific website to which the user has to be logged in. It is simple to logout the user, but after the logout the site requires the user to "close the browser". If the user only ...
0
votes
0answers
6 views

Return partial object in Vapor 3

I would like to return a partial object in a response for another object type. For example, I have a UserProfile model: var id: Int? var email: String var firstName: String? var lastName: ...
0
votes
0answers
15 views

Combine multiple joins with filters in Vapor

In my backend, I have Posts and a PostController. A post may be visibleToFriendOnly. In GET /posts, I want to return all posts that the current user is allowed to see. The User model has a friends ...
2
votes
1answer
27 views

Does marking a Swift class final also make all contained vars, lets and functions gain Static Dispatch benefits automatically?

I am trying to squeeze every last bit of performance out of my app. I try to use Structs over classes wherever possible (no state sharing, direct dispatch by default, etc etc). But my view ...
0
votes
2answers
25 views

How to append data to the end of a label in swift 4.0

I have a table view with options of grocery items with price which are stored in a dictionary. Once user selects a row from table view the item name and price is added to a dictionary and printed in ...
0
votes
1answer
20 views

iOS certificate that doesn't invalidate after 7 days?

I've created an app that I'm using for research for general data collection/exporting. As of right now I have to reinstall the app every 7 days or so because the certificate it's signed with becomes ...
-2
votes
0answers
20 views

IOS App to know when app is locked or using another app

Trying to figure out, with my app, how to make the app know when the phone is locked or when the app is minimized and using another app. This is what i have so far: //warning notification func ...
0
votes
1answer
21 views

How can I run a function before my extension code in Swift?

I am working on a project and am using a tableView to load data. The issue is that I need the number of cells to be determined by a specific function. My tableView sets the number of cells in an ...
0
votes
0answers
10 views

UICollectionView pushing cell's subviews down on scroll

When I scroll my UICollectionView, certain subviews are being automatically moved around. It seems to somehow be related to the status bar. Is this a view controller level setting I can turn off? ...
0
votes
0answers
7 views

Use of undeclared type - Swift - AWS Amplify

I am working through the excellent example app posted here: https://github.com/aws-samples/aws-mobile-appsync-events-starter-ios/tree/master/EventsApp I'm getting the error: "Use of undeclared type.....
0
votes
0answers
23 views

How to wait for initialization to complete before returning a singleton instance in Swift

I have a singleton class, which requires a network operation with asynchronous callback to initialize. Any member function of that class should only be called when initialization callback finished. ...
0
votes
0answers
19 views

Retrieving data for specific user using firebase

I'm making an attendance app and I'm trying to retrieve the data from the firebase database for each specific user. There are two users 16BCA1278 and 16BCA1282. These are the firebase rules, they ...
0
votes
0answers
10 views

What automatic adjustments from the AVFoundation camera are automatically adjusting by default?

I am trying to create an app using AVFoundation camera, that can detect variations on color levels. I have remembered that by default, the camera has auto exposure and auto white balance turned on. ...
0
votes
0answers
13 views

How to fetch Facebook profile link while logging in with SDK - SWIFT?

I'm trying to fetch user profile link from Facebook SDK. The problem is that when I'm making Graph Request, Facebook gives me all the info without user profile link. I was trying "https://facebook....
0
votes
1answer
16 views

Network requests timed out irregularly in Swift (using Alamofire)

We have been experiencing timeout issues with some of our requests very rarely and occasionally. It is difficult to reproduce as it just happens out of nowhere and on retry (resending the request by ...
1
vote
3answers
44 views

I'm trying to understand Optionals in Swift. Code works, but I don't understand why

I'm working on a task at Excercism and have been doing online swift courses for a while. I completed a task and saw this solution (which was much less code than mine). Why is this an optional? I don'...
1
vote
1answer
45 views

Get the value of an array as an integer and show on buttons in realtime

I would like to get the number of values in myKeyArray to print as an integer so that whenever a child is added or removed in firebase it updates. Currently it prints the number of values in the array ...
0
votes
1answer
11 views

Finish some animations from UIViewPropertyAnimator earlier

I search for a way to add some animations to an UIViewPropertyAnimator which finishing earlier then others. UIViewPropertyAnimator have for example a method where you can add animations with a delay ...
0
votes
3answers
19 views

how to add gesture recognizer to UIImage and UIButton of UITableViewCell?

I am trying to attach a gesture recognizer on a button and on an image view in a dynamic tableView cell, but I get error: *** Terminating app due to uncaught exception 'NSInvalidArgumentException',...
-2
votes
0answers
15 views

Can I change the backend of my app from cloudKit to for example Firebase later? How? [on hold]

I am currently developing a fairly complex app with a cloud based backend service which is the iCloud. I use the cloudKit framework just because I am currently developing for iOS, and it is completely ...
1
vote
0answers
20 views

How get identifier for vendor from website?

How can I get the identifier for vendor of my iPhone from a website page ? For example I create a Cydia repo, and I want that only peoples who paid for my tweak can download it. So to do that I need ...
0
votes
0answers
23 views

Weird Firebase observer behaviour Swift 4

I have a function that listen to Firebase for added and removed childs in my database. I do a print for the array where I store incoming data from database before observers and one after the observers ...
0
votes
0answers
18 views

Get equal and unique identifier for 2 apps installed in the same iOS device

I have two apps for iOS, one made with Swift and another with Ionic3, I need an unique and equal identifier for both of them. The Ionic app has user authentification but the other one doesn't have ...
0
votes
2answers
29 views

Problems updating UILabel text

I'm making a little game and I'am having trouble updating an UILabel I created to display the current score. Every time I try to update the score label the entire screen freezes up for a split second, ...
0
votes
0answers
12 views

Playing WAV data with AVAudioEngine

Currently, I'm getting an EXC_BAD_ACCESS error on the audio thread, and I'm trying to deduce what is going wrong. When converting .wav file data from Data to an AVAudioPCMBuffer, do I need to strip ...
1
vote
1answer
24 views

Why is Page Control not reflecting where I am on the UIScrollView?

After editing my UIScrollView size, page control stopped working. You can see there are only 3 slides. But (1) Page Control isn't reflecting which slide I'm on and (2) I can only scroll from slide 1 ...
0
votes
3answers
27 views

Does childViewControllers array have a specific order in a view controller with various containers?

I have a base View Controller with various containers inside it. I use them to control the current step on a process, and only one of them is visible at a time. I created a enum for the steps, and use ...
0
votes
1answer
9 views

Caching and Restoring TabBarItem Order

Is there a simple way to do this for a UITabBarController after the user has modified the original ordering? I got the following code to work but it feels a bit clunky. class TabBarViewController: ...
0
votes
1answer
15 views

How to encrypt and decrypt in swift like android cipher?

I have an android class which is encoding and decoding my text using a key but I want to create the same class for swift. “I'm setting up a new server, and want to support UTF-8 fully in my web ...
0
votes
2answers
23 views

Type Inference in tuples?

let http404Error = (statusCode: 404, statusMessage: "Not found") print(http404Error.0, http404Error.1) I got some questions and "problems" with tuples: Question 1: But what if I want the statusCode ...
0
votes
0answers
19 views

Incorrect use of objc_storeWeak() and objc_loadWeak()

When I run my playground I’m getting this in the console -                                                 objc[15647]: __weak variable at 0x7fbf98502830 holds 0x7fbf9850003d instead of ...
1
vote
1answer
18 views

Animate a view alongside a path without CAKeyframeAnimation

I want to animate a view alongside a path (without CAKeyframeAnimation) instead with UIViewPropertyAnimator. For that I have a path with start- and endpoint and a controlpoint to make a quadcurve. ...
0
votes
0answers
9 views

Sonarqube shows Bugs 0 & Vulnerabilities 0

i have: Sonarqube server: 6.7.5 based on Windows Server 2016 Sonar swift plugin: 0.4.2 Scanner on MAC OS X: 3.3.0.1492 Everything is good, but in the end of process of executing of sonar-scanner, i ...
-3
votes
1answer
27 views

How to pass data from ViewControllers and show them into tableviewCell?

I want to pass data from my ViewController to TableViewCell, How can I do that. How to pass data from one ViewController and show them in TableViewCell.
1
vote
1answer
18 views

iOS Swift how to synchronise chart drawing line, gradient and circle animations?

I try to synchronise animations of chart line, circle and gradient. Here is fancy chart gif with not synchronised animations :/ Run all animations code: CATransaction.begin() ...
0
votes
0answers
10 views

Why does instantiating a new Object with RealmOptional property cause EXC_BAD_INSTRUCTION crash in swift playground?

When my class includes a RealmOptional, the swift playground crashes with EXC_BAD_INSTRUCTION when I create an instance of my class. As soon as I remove that RealmOptional property, the Thing object ...
-1
votes
0answers
16 views

How to set up google populartimes api using python?

how to setup this lib in my swift code ? https://github.com/m-wrzr/populartimes/blob/master/README.md clone the repository, cd into the populartimes directory and run pip install . Alternatively ...

http://mssss.yulina-kosm.ru