Questions tagged [swift]

Swift is a general-purpose, open-source programming language developed by Apple Inc. for its 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
3 views

how to set header size of UICollectionView in swift 5.1?

In the lower swift I can use this function to set the size func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, ...
0
votes
1answer
13 views

Swift: How do I make a UIView Rectangle with multiple corner radii? I want the corners to be 25, 0, 15, 15

I've learned how to use layer.cornerRadius to round all the corners, but I want three different radii. I've found that I can use view.layer.maskedCorners = [.layerMinXMinYCorner] to choose a ...
0
votes
0answers
7 views

How to properly upload image to firebase storage

When my profile image upload to firebase storage no photo appears but there is no error in my code how do I fix this problem to correctly upload my user profile image to firebase storage? let uid = ...
0
votes
0answers
17 views

Alamofire 'Invalid type in JSON write (_SwiftValue)' struct

I am trying to make a Alamofire Post request and my Codable struct is failing. var items: [[InspectionUploadItem]?]? let params : Parameters = ["key" : key, "items": items] Alamofire.request(url, ...
1
vote
0answers
13 views

How to play sound in customer class and recognize the end of sound play

I want play a mp3 file in the swift application in a separate class (not in the viewController class) and recognize the end of sound. My code send an EXC_BAD_ACCESS in AppDelegate.swift. Here my code:...
1
vote
1answer
16 views

Animating a class that is an extension of UIView in Swift

I'm trying to get an instance of my Options class to animate onto the screen using the function appear() which activates when pressing a button in my SearchResult class but I'm having trouble, the ...
1
vote
1answer
14 views

.tag on slider not changing the alpha of imagview

My swift code below has 2 different buttons which should effect the slider baised on the .tagnumber they initialize. B1 should effect the alhpa or transpency of the imageivew and b2 should decrease / ...
0
votes
0answers
14 views

AV Player not working in a container view Swift

I am trying to get a video to play within a container view controller. I would like the video to play only within the container view but have the option to full screen it while playing. I have a ...
1
vote
0answers
14 views

How to access Delete Row function in a Multivalued row for a Eureka form

I would like to access the delete row function in the eureka form but I couldn't find how to do it. The reason is that I have an i variable that keeps track of how many rows I have and because of ...
1
vote
1answer
22 views

Using a variable out of a singleton method

I have to use the grade variable out of the .dataTask method (singleton) but when it returns the grades value it's nil. I've checked that into the function the variable isn't nil (in the for loop)... ...
0
votes
1answer
40 views

How to pick a two different random elements from a given range? [closed]

How to pick a two different random elements from a given range in Swift? Expected method signature: func pickTwoRandomElementsFromRange(_ range: ClosedRange<Int>) -> (Int, Int)? { /// CODE ...
-1
votes
0answers
11 views

Charts and Graphs on Apple Watch [closed]

I'm looking for a way to add charts and graphs on the Apple Watch. There's an old thread and library on Github that hasn't been updated in 2 years. Using Swift UI we can now compose graphics on the ...
0
votes
0answers
18 views

How to add a body to a https request in swift

Im trying to add the following raw data to the code though im not sure how to go about that fields name; limit 100; where rating < 60; To this code import UIKit import WebKit class ...
0
votes
0answers
16 views

Change colour of back bar button item only in swift

I am trying to change the colour of the back bar button item in swift navigation bar. Ultimately I aim to make something line this for the navbar: This is my current code which gives me three back ...
1
vote
0answers
9 views

Swift 4 - UIActivityViewController for Outlook

I am trying to use UIActivityViewController for outlook only...I was able to get my UIActivityViewController working like so: //Define HTML String var htmlString = "" //Add the ...
1
vote
0answers
6 views

SwiftUI Drag Gesture inside of the UIPageViewController

I have a SwfitUI project and start to build UIPageViewController. Inside the pages I have VStack like this: VStack { // some code hare }.gesture( DragGesture() .onChanged({ self.onDragChanged(...
0
votes
4answers
26 views

Auto-sizing a UILabel without setting an explicit height

How do I get a multi-line label to size itself? I don't want to set an explicit height for it but I do need to place it in view. The way my app is built, we explicitly set frames and origins rather ...
1
vote
0answers
14 views

Function declares an opaque return type, but the return statements in its body do not have matching underlying types [duplicate]

I need use a if-else statement to get different results like the code below, but got the error "Function declares an opaque return type, but the return statements in its body do not have matching ...
0
votes
1answer
23 views

Have a version compatible with iOS 11 - iO12 and another with iOS13 (swiftUI)

I have my app approved in the appstore: Version 1 made with SwiftUI for iOS13 ↑ Version 2 made with Storyboard for iOS11 - iOS13 Version 3 made with with SwiftUI for iOS13 ↑ (Future versions all with ...
0
votes
0answers
6 views

CoreData is it possible to safely use NSManagedObject from one context/thread in another context/background task

Is it possible to use NSManagedObjects between different background Task? I have such code that when executed loads NSManagedObjects using load() method on one context/background task using inside ....
1
vote
1answer
23 views

adding a button programatiy to UITabBar is moved when dismissed a modal ViewController

I'm adding a button programaticly to TabBarController using this code: let tabBarHeight = tabBar.layer.bounds.height * 1.2 let win: UIWindow = ((UIApplication.shared.delegate?.window)!)! ...
0
votes
0answers
15 views

Monitoring Keychain item changes in Swift

The Keychain Services API allows adding/updating/deleting items from the keychain. However, it doesn't seem to include any mechanism for watching a specific keychain item for changes. My app is ...
1
vote
1answer
26 views

Change tableView Cells by choosing different cells from collectionView which is the Header of tableview

I have the collectionView as my tableview header. Now I need to change the cells of the tableView depending on the cell I choose from the collection view. How do I do this from didselect of the ...
-1
votes
0answers
15 views

Tinting a bunch of views with different colors which could be expensive. What is the right way to optimize this? [closed]

I have a color based picker that shows a bunch of small circles with different colors. I have the hex codes to color mappings and I am planning on tinting a bunch a views to achieve what I just ...
1
vote
0answers
18 views

SwiftUI TabView Rearrange Tab Order Preservation

It looks like Apple's TabView supports rearrangements automatically, but it quickly loses a rearrangement after you click on a tab. Here's my playground code. import SwiftUI import PlaygroundSupport ...
1
vote
1answer
19 views

Get firebase message from sender and receiver

I am using firebase for simple chat application. I am looking to fetch messages of user 1 and user 2. My database structure look like this. I am using queryOrdered to fetch messages but it will ...
0
votes
0answers
10 views

How to save encoded CMSampleBuffer samples to mp4 file on iOS

I'm using the VideoToolbox framework to retrieve data from AVCaptureSession and encode it to h264 and acc. I'm at a point where I: obtain data using the delegate method func captureOutput(_ ...
1
vote
0answers
21 views

I can't delete a custom album with its photo using PHPhotoLibrary

I'm having hard time trying to figure out how to delete the custom albums made by my app along with its photos. NOTE: I can delete albums but not along with its photos. THE CODE I'M BASING ON FROM ...
-2
votes
0answers
17 views

Update price product in view controller Swift [closed]

I have problem in view Controller the first time show price product from api then if product is configure show more details from this product must chose one drop down and check box and radio button ...
1
vote
0answers
20 views

iOS UI testing - picker wheel adjusting only swipes by one item

I am trying to write a test for UIPickerView to pick certain values. I use picker.adjust(toPickerWheelValue: pickValue) to do so. But the problem is that for some reason this only swipes picker by one ...
1
vote
1answer
42 views

Time and date formatter SwiftUI JSON data

Hopefully this an easy one. Im trying to display the date and time in a list In an iOS application using SwiftUI. I'm having issues with the code at the moment and getting this error message: Cannot ...
0
votes
0answers
8 views

SideMenu coming separately in updated macOS catalina and updated Xcode 11.2.1 in swift

I have recently updated macos from mojave to catalina and xcode from 10.14 to 11.1.2. in previous version i am getting sidemenu properly but in updated version side menu coming separately, why? i ...
0
votes
1answer
15 views

Binding visibility to arrayController selection

I have a NSTableView bound to a NSArrayController. I have two buttons below the table that must be enabled only if there is an element selected on the table. I select the buttons and bind ...
0
votes
2answers
26 views

How to send nested raw JSON in URLSession to Vapor API?

I have a Vapor API that has a route to register users. This route recibes a nested object in JSON format like this: { "name": "Test", "email": "[email protected]", "password": "Test1", "...
1
vote
1answer
19 views

How do I call a fromRootViewController method within a UIView class?

EDIT: This is a very beginner level question, so I apologise in advance This is a sub part of a homework assignment I'm trying to crack but seems kind of impossible. I have implemented ...
1
vote
1answer
46 views

Swift encode class without nesting super class

Summary: I would like to encode all fields of my super class without nesting them in the json result. Here's what I mean: Let's say we have these structs: struct Toy: Codable { var name: String } ...
1
vote
2answers
43 views

How to write a swift function that returns one of three types?

I have three view controllers, WebkitViewController, and then two other view controllers WebkitViewControllerA, and WebkitViewControllerB that both extend WebkitViewController. I am having trouble ...
0
votes
0answers
12 views

Show iOS audio output device list pop-up programatically [closed]

I want to open native popup for my iOS app audio output devices: The app Zoom has direct access to this popup but I am not able to get access to it. Please suggest me how we can do this in Swift.
0
votes
0answers
18 views

Working with expandable tableview cells and dequeueReusableCells

I've set a up a simple project to test out various TableView functionalities in swift, in particular enabling expandable cells. I've gotten the expandable cell to work, in this project the first ...
0
votes
1answer
28 views

How can you make an escaping completion handler argument optional?

I've got a method as follows, sometimes being called with a completion handler and other times not, how can I make it optional? func someFunc(completion: @escaping () -> Void) Looked at several ...
0
votes
0answers
5 views

KolodaCardStack datasource not displaying cards

I'm trying to implement a card stack into my ios app but I can't seem to figure it out. I'm using and I've given the view itself a red background. I can clearly see the background when running the ...
0
votes
1answer
17 views

Collection View inside UITableView reuse issue

I have a TableView with a CollectionView inside. So each Table cell is the delegate of the CollectionView. The problem is that the collection View reloads on the main thread and the UITableView Cells ...
0
votes
0answers
9 views

'NSTaggedPointerString' (0x7fff87a8a270) to 'NSNumber' SQLClient

I am pulling data with the SQL client. The data I retrieved from the table is int. But I get the error in the title. What should I do? Table data is an int value. @IBAction func ...
0
votes
1answer
35 views

In Swift Combine Publisher, I am getting conform to 'RangeReplaceableCollection' error

I am getting the following compiler-time error, for a Swift publisher solution I am working on: Instance method 'store(in:)' requires that 'Set<[AnyCancellable]>' conform to '...
0
votes
0answers
19 views

Can i create a an iOS framework conforming to an inside protocol and also define the same protocol in my project?

i'm creating a framework the conforms to a certain protocol MyTestFramework.framework public protocol SBFProtocol { static var sharedInstance: SBFProtocol { get } func GetVersion() -> ...
-1
votes
1answer
10 views

Swift Generic Conversion NSManagedObject to/from Object with inverse Relationship [closed]

I'm trying to extend the here proposed solution https://swifting.io/blog/2016/11/27/28-better-coredata-with-swift-generics/ for entities that have many-to-many relationships, but I didn't find yet a ...
0
votes
0answers
11 views

IPA file is not opening in updated macOS catalina and Xcode 11.2.1 why in swift?

I have recently updated Xcode from 10.14 to 11.2.1 and macOS from mojave to catalina. in my previous version i am able to get ipa file which i can use in https://www.diawi.com/ but now my ipa file ...
-2
votes
0answers
24 views

Is this CI flow good to implement for iOS App? [closed]

is this CI flow good to implement, here development branch will be protected branch, and it can be only changed by approving PR? so by default merge button will be disabled when we create PR on it. i ...
0
votes
0answers
19 views

Thread 1: EXC_BAD_ACCESS (code=2, address=0x16d8d7ff8)

I created a PieChart with a own class for the UIView and inside this class the loadNib() method throws this error. required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) let ...
0
votes
0answers
16 views

How to properly animate cells of a UICollectionView with size constraints?

I have a collection view which can be scrolled horizontally, and grown/shrunk vertically with a pan gesture. The collection view cells must always follow the collection view height (as the content ...