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
5 views

Is it possible to upload while device is locked in iOS?

Is it possible to do an upload while the phone is locked or it's an OS restriction? Are there apps out there that have done it? I've been searching for a while on a solution for uploading data while ...
0
votes
0answers
9 views

UINavigationBarAppearance not working for image based bar button items

Xcode Version 11.0 beta 5 (11M382q) I'm using the new appearance APIs to tint the color of the bar button items when one of my view controllers is the top view controller. I'm using the following ...
-2
votes
0answers
11 views

How can I solve this XCODE Thread 1 SIGABRT error? I tried renaming the outlets and deleting the previous from the system

it is an xcode error labeled as "Thread 1: signal SIGABRT." it is crashing my app. I tried renaming the outlet and removing the old one from the system; it does not go away! import UIKit @...
0
votes
0answers
4 views

Are URLSession objects resource intensive?

Would it be resource intensive to create a new URLSession for every single web request? Some background: I'm working on a library for making web requests. I'm trying to add a feature that allows ...
0
votes
0answers
8 views

How to apply a gradient on tab bar items in Swift

I have a custom UITabBarController set up, and I want to apply a gradient (with multiple colors) on selected tab bar items. Please note that (1) it's the selected tab bar items I want to apply a ...
1
vote
0answers
7 views

iOS UITextInput control: Receiving forward-delete key from hardware keyboard

I have implemented a complicated UITextInput that works quite well on iOS save for one missing feature: when the user has a hardware keyboard connected (at least, in the simulator) and no text is ...
1
vote
0answers
28 views

Fail to parse json

I have problem with the parsing a JSON for a public weather API. here is the screenshot of the Json. { "data": [ { "rh": 66, "pod": "n", "lon": 11.03, "pres": ...
1
vote
1answer
16 views

How to drag a working slider using SwiftUI

I would like to drag a slider and of course have it slide as well. I can do one or the other, but I cannot do both. How can I drag and have a working slider? I also tried to find a way to remove a ...
0
votes
0answers
12 views

I lost reference to my propertie in view model

I get the dates from API, this is ok, but when i set the propertie Fund, i lost reference. This is make with Swift 5 with class Result to use the completion, but i lost the reference, i can get date ...
-2
votes
1answer
18 views

CLLocation found nil after using CLLocationManagerDelegate

I want to get longitude and latitude, and I add CLLocationManagerDelegate in the controller. here is my code let locationManager = CLLocationManager() func getWeatherInformation(){ var ...
0
votes
0answers
13 views

From the user's current location, how would I change the color of the closest annotation to the user in the MKMapView?

I would like for the user of my app to know which annotation on the map is closest to them and to be able to show this by turning that specific annotation a different color. The current location of ...
0
votes
1answer
42 views

When does the == operator depend on Equatable and when does it not?

I have an array of the following struct: struct AtomCameraType { var APIIdentifier: Input.HDRCamera var name: String init(... } That APIIdentifier, of type Input.HDRCamera, is a ...
0
votes
0answers
15 views

FirstResponder ignitable only in a little piece of a textView

I have this textView in the inputAccesoryView, the case is that the textView have 80 of height and all the screen of width. Problem: the finger will init the firstResponder only within the first 10 -...
-2
votes
2answers
21 views

swipe recognizer get only one direction recognized

swipegesturerecognizer recognize only the right direction. left, up or down did not recognized and not even calls the selector am using swift 5 Xcode 10.3 func setupUserInteraction(){ self.view....
0
votes
0answers
21 views

App runs on device or simulator but release .ipa build crashes

I have an issue where my app works just fine if I run it directly onto the device (iPad) from XCode, or on an iPad simulator. But when I create an Ad-Hoc build, or upload to Testflight, the resulting ...
-1
votes
0answers
10 views

How do I add/attach events, or buttons on 3d meshes?

I just recently started using swift as my language, and I am currently working on my 3d mesh/model. I would like to know how to add/attach events or buttons on my mesh.
2
votes
1answer
16 views

How to make a NSSound loop

I'm attempting to make a simple application on XCode (in Swift) that plays an audio file, then keeps looping infinitely. According to Apple's website, I need to add var loops: Bool { get set } to my ...
3
votes
0answers
18 views

skipPrevious and skipNext buttons inactive even with items in queue Google Cast iOS Sender SDK v4.3.5 and above

I have an iOS sender application for video streaming that supports queueing and using the skipPrevious and skipNext buttons to skip forward and backward between videos in the queue. The app works with ...
-4
votes
0answers
20 views

want to active Action PickerView [on hold]

let writenpicker = ["ايقاف", "٥ دقائق", "١٠ دقائق", "١٥ دقيقه", "٣٠ دقيقه" , "١ ساعه"] let soundpicker = ["ايقاف", "٥ دقائق", "١٠ دقائق", "١٥ دقيقه", "٣٠ دقيقه" , "١ ساعه"] func numberOfComponents(in ...
1
vote
0answers
18 views

How to use Django's RestAPI's update() function in models with swift?

I'm currently trying to link swift and a database (MySQL) using Django's Rest-API Framework. I've already Django and have it connected and it gets Post requests and Get requests fine. I'm just ...
1
vote
1answer
44 views

collectionView didSelectItemAt superview not selecting the correct Object

I have a list of sensors in a collectionView inside a UIView class called MyCropView where I show some data about that crop. Im trying to change the value of some sensors like the icon and the ...
0
votes
1answer
16 views

Adding characters automatically to searchBar textField while user is typing?

I am wondering if there is a way to add characters automatically to a searchBar textField while the user is typing. For example, if the user typed 533 then I want to automatically add " X " to it. I ...
0
votes
1answer
22 views

Segue transitions to the wrong page Swift Xcode

I am trying to create a series of pages that work in tandem using custom segues. These segues work fine until I have them execute in a certain series. From VC1 I go to VC2 via the default modal segue (...
1
vote
0answers
18 views

How can I get multiple names of ARReferenceImages to return the same data from a JSON file?

Let's say my JSON file looks like this: [ { "name": "Composting Toilet", "saving": "3", "type": "Water" }, { "name": "Ceiling Fans", "saving": "4", "type": "Energy" }, ...
-1
votes
1answer
44 views

My Question is about changing a UIImage when a button is pressed

So I am quite new to coding, learning Swift 3 on Udemy. I'm trying to test my skills by building a music app that contains 3 sound files, at the moment I am struggling to get the image of the current ...
1
vote
1answer
24 views

Using ForEach loop with Binding causes index out of range when array shrinks (SwiftUI)

I have an app that Individually extracts every element of an array (through indices) Then bind it to a struct that can make use of that single element (viewing and editing) But every ...
0
votes
0answers
7 views

Empty EKEventStore calendar list after authentication

I would like to grab the names of my calendars on my Mac. I have 1 that's listed as "On My Mac", another (Birthdays) under "Other", and 4 that are pulled in from Google Calendar. let eventStore = ...
0
votes
0answers
14 views

Combining 3D and 2D in macOS

I need to draw 2D legends, 2D frame, etc. on top of a 3D scene. Here, I am trying to display a 2D label on top of a 3D sphere, so that the label will always face the user, even if they rotate the ...
1
vote
0answers
15 views

Observing .effectiveAppearance change from appDelegate

In my appDelegate's applicationDidFinishLaunching method, I would like to observe the appearance change from light / dark mode. Neither of these seems to do the trick: NSApp.observe(\....
0
votes
0answers
14 views

Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory

i want to download files from api and save it. my code work then stop and show me this error: Task <4F489168-F25C-4775-B7A9-6C1ECC8510B6>.<7868> load failed with error Error Domain=...
-1
votes
0answers
13 views

IOS To External Display Slideshow [on hold]

I want to display a slide show on an external display controlled from an ipad. I want to achieve this in any Wired or wireless way like airplay. Just that the main active screen on the iPad will be ...
1
vote
0answers
17 views

Annotations are hidden when zooming out

This is my problem: When zooming out and property showsUserLocation is set to true and the annotation are centered around the users location, clusters will disappear when zooming out. I don't want ...
0
votes
0answers
9 views

tzdata freeze docker build Swfit image

While run docker build to build a swift image, tzdata will stop the process. It prompt to choose a location, but no reaction after I enter the number . Configuring tzdata ------------------ ...
-1
votes
0answers
38 views

Date(String) convert in the get of a variable in the struct

In my model, I have a struct that contains a variable for Date in String. This variable later gets the value from the server and passes it to the controller. struct ArticleData: Decodable { var ...
0
votes
0answers
28 views

Change var from another class always empty?

I tried to set userName from another class but userName is always empty. Why? Class: Page2 let name = value?["username"] as! String //I pretty sure name is not empty ProfilePage()....
-3
votes
0answers
9 views

Swift Collection View Dynamic view overlap issue [on hold]

I am facing an issue regarding dynamic view in UICollection View. The views are getting overlap with each other
0
votes
0answers
21 views

SwiftUI Canvas won't build

I have some SwiftUI code and it seems to work great when I build to a real iOS device or to an iOS simulator. However in the SwiftUI canvas the preview says Failed to build MySwiftUI.swift clicking ...
-1
votes
2answers
37 views

Why are my iOS images not appearing when I run my app?

I'm creating a simple dice rolling app but when I run my project, the dice don't appear. class ViewController: UIViewController { let diceArray = ["dice1", "dice2", "dice3", "dice4", "dice5", "...
0
votes
1answer
16 views

How to pass complex dictionary which contains array of model objects with alamofire?

I need to pass following parameters in my Alamofire request {"order":{"student_id":"1483","restaurant_id":1,"quantity":1,"total_amount":90.0,"total_discount":0.0},"items":[{"item_id":"1","offer":"0.0"...
0
votes
3answers
35 views

Suggestions regarding UIImageView customization

I'm trying to figure out the best way to recreate this image in code. I've thought about taking two UIImageViews and connecting them via constraints but that would only get me 50% of the way there ...
-1
votes
2answers
21 views

Check if user already has an account just by email

How do I check if a user exists in my Firebase Database only by email within Swift? The first screen the user should see allows him to type in his email. After that he gets to the sign up page or the ...
1
vote
0answers
19 views

How to read a pre-loaded sqlite database in swift

I am trying to load a pre-loaded sqlite database with .db3 extension but getting error "unexpectedly found nil" I embedded the file in targetapp >> BuildPhases >> Copy bundle resources. let dat = ...
0
votes
0answers
20 views

How to push UIViewController with clear background on navigation stack

Image screen layout. I want to navigate between view controllers inside of navigation and keep still image as a background for all viewcontrollers. So I tried to set image background of ...
0
votes
1answer
23 views

How to determine whether the macOs app was launched via a url

I need to know whether the app was launched via an URL in DidFinishLaunching. The notification parameter in DidFinishLaunching contains a key LaunchIsDefaultLaunchKey which according to Apple ...
-2
votes
1answer
36 views

Convert date format from json data in the model and then pass to controller

Here in my model I have a few struct to handle the data from server struct Articles: Decodable { var content : [ArticleData] } struct ArticleData: Decodable { var title: String var date_time: Date ...
-7
votes
2answers
40 views

How to make a swift get query to specific url [on hold]

I am new to swift programming and need sam help. I want to know how I can make a get query to specific url and save the response data to variable. I am sorry that I can't show you the url but its a ...
1
vote
0answers
30 views

Add SwiftUI View to an UITableViewCell contentView

I'm currently trying, to implement a UITableViewController in a UIViewControllerRepresentable, where the contents of the cells are SwiftUI Views again. I cannot use a SwiftUI List, because I want to ...
0
votes
1answer
42 views

Xcode Playground crashes with a simple UITableViewController code

I encountered a very strange problem with a UITableViewController subclass instance in the Xcode Playground. I registered two UITableViewCells programmatically in viewDidLoad, and dequeued cells in ...
0
votes
1answer
30 views

Collection View Cell Action using Delegates and Protocols

I have created a View Controller that contains a UITableView and each UITableViewCell contains a UICollectionView. I made 2 API calls and every collectionView present the first 5 results of each API ...
0
votes
2answers
50 views

How to create and run a Thread in Swift using the Foundation framework?

I want to create a simple thread in Swift. I've no previous experience with Objective-C, so I find the documentation pretty confusing, including terms like "receiver", "selector", and "target" - ...