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.

0
votes
1answer
5 views

Adjust view's height to containing table view's row amount

I want to implement a dropdown containing a table view with dynamic cells, hence the height won't be static. The table view is being updated when the user adds an item, since I don't want any white ...
0
votes
0answers
7 views

Firestore query geohash filtering

Firestore query question. I have a "geohash" field in my document which I want to filter by. I have seen Frank's @puf video about getting circular geohashes on yt. For now I don't care about a ...
0
votes
0answers
9 views

Adding a shadow over an image in Swift

This project is taken from SwiftOCR by garnele007. There is a NSImage (That is also converted into a .png for saving)in the Swift project that I would like to add a shadow on top of. Several examples ...
-3
votes
0answers
12 views

What is the best approach in swift for json data in swift

What is the best approach in swift for json data.....to save it in a file or coredata..... I want to show prayer times in my app and also show ialamic calendar what is the best approach for saving ...
0
votes
0answers
10 views

CGPoint displacement to pitch, roll and yaw

Hello fellow DJI SDK developers, I'm using the DJI sdk to control the osmo mobile gimbal using my custom iOS app. What DJI has done is incredible impressive, and I'm excited to continue to build on ...
0
votes
1answer
25 views

Why ReturnType is not working in this Swift function?

I am working with Swift 5, in Xcode 10.2.1 I have this function inside of an extension of UInt8 The compiler complains in line 5, with Unexpected non-void return value in void function The return ...
0
votes
0answers
13 views

Swift Firebase fetch user [duplicate]

I want to make a little social media app where a page can fetch registered users from a Firabse database into a TableView. I am following this video but at 14.23 my code gives me an error. https://www....
-1
votes
1answer
10 views

Centering between two anchors

I want to set a centerYAnchor between two anchors. Similar to this: centeredLabel.centerYAnchor.constraint(equalTo: view.centerYAnchor), However, I don't want it to be centered relative to the ...
0
votes
0answers
5 views

How to take care of Orphan Letters in a UITextView that resizes its font

I'm resizing the font of a UITextView but i'm having issues with orphan letters, i'm using this exact same code to resizing the text font: https://megam.info/a/27115350/5442219
0
votes
0answers
24 views

append values/parameters to struct in swift

I am trying to pass parameters to a struct in swift but this way of dealing with structs is a bit too far for me. First of all, I am getting all values from a model that I have created. This model ...
-1
votes
0answers
10 views

Is it possible to synchronize multiple display updates to the same draw cycle?

I have an infinite scroll view situation with a bit of custom drawing going on (a stock graph). At the point I need to recenter, I set the new contentOffset and redraw the content, but it appears ...
0
votes
1answer
14 views

GMSPlacesClient autocompleteQuery returning nil

autocompleteQuery results consistently return a nil no matter the situation I'm a little rusty but I know this worked a little over a year ago when I did a slightly similar project //search ...
-1
votes
0answers
19 views

How to make a Swift application scriptable?

How can I call a simple function like this from AppleScript? func showAlert() { let returnText = "Alert!" print(returnText) } In AppleScript I'd like to call the function like this: tell ...
0
votes
0answers
13 views

How to animate CATextLayer width with smooth text growing

I have a CATextLayer inside UIView. I animate UIView frame for growing with UIView.animate(withDuration: 3.0, delay: 0, options: .beginFromCurrentState, animations: anim, completion: nil) Also I ...
0
votes
1answer
18 views

Swift iOS -How to set one user's formatter.locale from another user's formatter.locale

userA is in France, they set a price for something to €10 and I get their currency info and I record a copy of their local region to the db using Locale.current.identifier which gives me € and I save ...
-2
votes
0answers
16 views

How to retrieve images from database using swift

I have a website where images are uploaded and I am trying to retrieve those to display on a mobile app utilizing swift code. When querying the database it is returning only the image name (as seen ...
-1
votes
1answer
20 views

Blur image performance issues on iOS simulator 10.2.1

I use this code to blur my UIImage extension UIImage { func blurred(radius: CGFloat) -> UIImage { let ciContext = CIContext(options: nil) guard let cgImage = cgImage else { ...
0
votes
0answers
11 views

Swift - Change scroll velocity in targetContentOffset method

I didn't find the answer to my problem so decided to create a question I'm using in a subclass of UICollectionViewFlowLayout the method: targetContentOffset(forProposedContentOffset ...
0
votes
0answers
17 views

read/write database path using sqlite.swift

I'm just starting out trying sqlite.swift and databases with swift. I have prepared a database with tables and preloaded with data. I wish to select data and insert data from within the app. The ...
0
votes
2answers
14 views

How to dismiss keyboard on UISearchBar touchesBegan in swift 4

I have searched items in table view using UISearchBarDelegate. I have set search bar variable's delegate to self like so searchBar.delegate = self touchesBegan function I have used to hide keyboard....
-1
votes
1answer
13 views

Why is collectionView-cell suddenly bigger?

Using swift-5.0.1, iOS-12.2, I observe a strange behaviour on a UICollectionView: There are screen-wide cells that show an image inside my collectionView. My observation is that whenever the image ...
-1
votes
2answers
34 views

Decomposing a number into powers of 2

Hi I need to decompose a number into powers of 2 in swift 5 for an iOS app I'm writing fro a click and collect system. The backend of this system is written in c# and uses the following to save a ...
-2
votes
1answer
25 views

Swift: Recursive Loop and Flatten Array

I want to better understand recursive looping and flatten in Swift or any other language for that matter. I have a simple Swift class class Survey { let items: [SurveyItem]? } class ...
0
votes
0answers
10 views

IQKeyboardManager not bumping up UITextView with each new line of text

I'm using IQKeyboardManager in my project and it works great other than one issue. I have a UITextView where my users enter comments, when the keyboard is shown the text view moves up as it should, ...
0
votes
0answers
14 views

Fetching arrays using FetchedResultsController

I have the following two variables and fetch request as follows, var histBooks = [String]() var bookDescs = [String]() let request = NSFetchRequest<NSFetchRequestResult>(entityName: "...
0
votes
1answer
24 views

why is navigationBar hiding collectionView?

Using Swift-5.0.1, iOS-12.2, I successfully was able to place a UICollectionView with screen-wide cells with the custom height of 150 pixels. However, the navigationBar is hiding the first cell. I ...
0
votes
1answer
16 views

How do I add a background to a scroll view and have it repeat to the end?

I am making a roster on a scroll view with every slide being someone different. I was wondering if there is a way to set a background and have it repeat to the end as it cuts off at a certain person ...
0
votes
1answer
11 views

definesPresentationContext should be set to YES, but breaks navigation when used in combination with a UISearchController

For a setup with a UISearchController in a regular UIViewController (that also has a table view with some items), I get the following warning The topViewController of the navigation controller ...
0
votes
1answer
27 views

iOS constraints broken on emulator for labels

I am building a notes app for iOS on xCode. In the storyboard I have a table view > table cell > content view; and then inside the content view I have three labels. I'm running into problems ...
0
votes
0answers
14 views

Siri Shortcut for button action that sends message to a list of contacts

I have a button on the home screen of my app that gets the user's current location and sends it, along with a custom message, to a list of contacts. I now want to be able to create a Siri Shortcut ...
0
votes
0answers
26 views

How do you horizontally autoscroll a right-aligned UILabel to the right?

I'm trying to make a simple iOS calculator and need to get the label that shows the calculation to automatically scroll horizontally to the right. I can get it to scroll correctly if it's left ...
0
votes
1answer
35 views

Is it possible to create unwind segues programatically?

My app has a navigation controller where the first view controller is a login screen and all other screens are pushed on top. I would like to unwind to the login screen whenever any http request to ...
0
votes
2answers
23 views

Dynamically change text view height based on number of lines

I am dynamically changing the height of my text view based on the number of lines in my text view. I'd like the text view to start increasing in height after the 6th line. My current implementation is ...
0
votes
0answers
15 views

How to correctly render points in SceneKit with colours including alpha values?

I am trying to render a collection of points in SceneKit all of which have an alpha value less than 1 as part of their colour. While this seems to work, it depends on the angle at which you are ...
0
votes
1answer
11 views

the func didTapAt coordinate is not showing anything

i'm trying to het a marker position once the user taps on the map via the didTapAt coordinate function but the event don't trigger i don't know why i've tried different function like didtap on ...
0
votes
3answers
34 views

Parsing User from json that has user object inside (with Codable)

Let's say that I have following User object: struct User: Codable { let id: Int } And getting following json from an API: { "user": { "id": "22" } } Obviously, the codable user ...
0
votes
0answers
24 views

Tab bar button throws NSException error, why?

Issue I am using Xcode 10, Swift 5. I tried to rename some variables and arrays. I changed them all back to the original name though. After I did this my tab bar button throws an error at AppDelegate:...
0
votes
2answers
36 views

Change variable based on indexPath.row

I have four different variables, called display0, display1, display2, display3. I then have a collectionView, with a reusable cell that has a textLabel inside it. There will be four cells, whose ...
1
vote
1answer
15 views

Observing realm changes are not firing

In my application I have a custom RealmDatabase class. It initializes the Realm database for me. public class RealmDatabase: Database { let realm: Realm // // I also provide a shared() ...
0
votes
0answers
5 views

MapKit Directions move visible MapRect

To get a direction and to draw a rout polygon between two lines I set up a function. It works fine, but I'm struggling with centering the visible MapRect inside of the mapView. To see my current view ...
0
votes
1answer
23 views

iOS didSelectRowAt row on UITableView not working

I am trying to follow-up with this tutorial on CodePath: Visit https://guides.codepath.com/ios/Search-Bar-Guide#cancelling-out-of-search-and-hiding-keyboard I created a SearchViewController to search ...
1
vote
2answers
29 views

Search in dictionary on a variety of conditions Swift

I have simple dictionary var countOfR = ["R0": 0, "R1": 0, "R2": 0, "R3": 0, "R4": 0, "R5": 0, "R6": 0] I need to check this dictionary by multiple conditions. For example, next statement works ...
0
votes
1answer
31 views

Use truncatingRemainder() method in Obj-c

I am trying to create a 3D cube animation in objective-c.Here is a piece of code that I would like to use my code. Does someone knows how to convert these method to objective-c ? I didn't find ...
0
votes
1answer
27 views

Is NS_CLOSED_ENUM actually uneditable?

According the Apple docs, the new NS_CLOSED_ENUM macro added for Swift 5 is unchangeable. How is this possible? Can't I just clean the build, add a value, and recompile my app? Important Once ...
0
votes
0answers
18 views

search bar & firebase code is not working! can u fix? [duplicate]

I have a search bar connected to a Tableview and I don't know how to make it work! The table view is a table view of "Memories". memories have title, user id, body... and I want it too be able to ...
0
votes
0answers
11 views

After implementing background location updates FCM gone mad and are sent continuously without programmed trigger

I am creating simple chat app using Firebase. My database has node for messages, and when user gets message from another user - cloud function monitors changes and sends firebase cloud message to user'...
0
votes
1answer
22 views

How to add UICollectionView to the inputAccessoryView

I want to add UICollectionView to the inputAccessoryView so that I can scroll the list. override var inputAccessoryView: UIView? { let customView = UIView(frame: CGRect(x: 0, y: 0, width: 10, ...
0
votes
1answer
18 views

Swift Universal Framework not working in other app project

I created Swift Universal Framework and added external library via pod , but when i used universal framework in other app project, It gives diffrent - diffrent error while compile the project like-: "...
0
votes
0answers
14 views

Observe two sources of data at once

I'm learning RxSwift and RxCocoa. I've run into this problem: I have UITextField and UIPickerView and UIButton. UIButton should become enabled once UITextField is valid. There is different validation ...
0
votes
1answer
29 views

UIRefreshControl in UIScrollView Doesn't disappear on endRefreshing

I tried to use a UIRefreshControll in a UIScrollView but I had the problem that I needed to scroll a lot in order to get it to refresh. I needed to use both hands to make it work so I decided to write ...