Questions tagged [swift4]
Use this tag only for questions directly related to changes in version 4 of Apple's Swift programming language. Use the tag [swift] for more general language questions, or the tags [ios], [cocoa], [apple-watch] etc. for questions about developing on Apple platforms.
5,687
questions
0
votes
0
answers
17
views
Polygon break in MapView after iOS 15.0 update
When closing lines of a polygon that after the third point in the map marking calculates an area between the points, it presented an error after the iOS 15.0 update. Some tests they work but most ...
0
votes
1
answer
44
views
Swift migration: 'Notification' is ambiguous for type lookup in this context' in some places
I'm making a migration from Swift 2.3 to Swift 5 with a lot of pain and well, I'm ending the migration but I'm still getting an error in some places of the code:
Notification' is ambiguous for type ...
0
votes
1
answer
40
views
UIApplication.keywindow ,must be used from main thread only warning
DispatchQueue.main.async {
}
This cause error in my Extension
How I use it
let topController = UIApplication.shared.topMostViewController()
0
votes
0
answers
12
views
UITabbar NavigationBar Button overlap issue
I have used programatically to create tabbar , my views are like
navigationController - > login -> tabbar with NavigationBar button
First tab have : Left bar Image (button (logo), Right (...
0
votes
1
answer
27
views
Replace Gradient colors with ThemeSwift library (Library used for App Theme management)
How to use this library for gradient colors as they haven't mentioned the usage of gradient with ThemeAnyPicker in their documentation.
I am using plist method which is much easier way than the other ...
3
votes
0
answers
173
views
iOS 15 - UICollectionView disappear while scrolling only in iOS 15
this is the second time I posted here about this issue and no one could help me
my project was good in iOS 14 and previous versions when I debug my app on simulator or real device that have iOS 15 the ...
0
votes
0
answers
38
views
Wrap pdf vertically in swift
I have few pdf files where the person who reads has to zoom in and pan around to move to next paragraph.
Is there anyway i can view pdf in PDFKit or Webkit by just wrapping the texts in pdf and ...
0
votes
0
answers
100
views
iOS 15 - Widgets not refreshing
I have setup 2 widgets for my app.
Audio recording widget
List the 5 latest recordings
The first widget has no issues with refresh. It shows proper duration values and start/stop recording button ...
1
vote
0
answers
33
views
Create Long length Haptic in iWatch swift
Hi i am aware that apple does not allow us to create core haptic in iWatch instead it make us to use the default haptic it has. But the default haptics are of short length. Can I get help to know how ...
0
votes
0
answers
43
views
Need to know why am I getting empty receipt when I uninstall and reinstall app for in-app purchase functionality
I am using pod "TPInAppReceipt" for validating the receipt. I have implemented the auto-renewable subscription in my project by using Xcode store kit config.
Need help to know why I am ...
0
votes
2
answers
88
views
How to allow only single UIViewController to rotate upside down with Xcode?
In my app all screens have portrait orientation. How to allow only single UIViewController be in two orientation mode: portrait and upside down? When user rotates an iPhone, the UIViewController ...
0
votes
0
answers
12
views
Alamofire - swift 4 - upload using soap - (was working in swift 3) - deprecated variable
In swift 3 i had this line :
multipartFormData.support4SOAP_MTOM = true
In swift 4 i cannot make it work. I am not sure what is going wrong either.
2
votes
0
answers
90
views
How can I use old binary library TinyCrayon on latest iOS project?
I tried to use TinyCrayon in my new iOS project.
The library consists of a binary library framework. The link of the framework is dead in the TinyCrayon readme but it can be found here.
When I add the ...
0
votes
2
answers
121
views
how to put default value in fetch request predicate in coredata ios?
im working in ios swift, here i have used core data to store values and written some function to find the data and return it.
public func insertdetails (id:String, data:String, createdAt:String){
do{
...
0
votes
1
answer
423
views
Swift generics issue: generic parameter could not be inferred
With this code:
public protocol LoginInfoBase: Decodable {
var access_token: String? { get }
var notifications: [PushNotification] { get }
}
public class ExampleLoginInfo: LoginInfoBase {
...
-2
votes
1
answer
163
views
Why does the large title not work when I use the Turkish character "ç"? [closed]
Why does the banner not work when I use the Turkish "ç" character?
I've tried everything, everything seems fine. But I only get such an error in the "ç" character, has anyone ...
1
vote
1
answer
263
views
Unable to download PKpass from server
I've been trying several links to download pkpass from server but whenever i download it it shows me the size of file "0 kb", due to this i cannot convert it to pkpass data.
is there any ...
0
votes
1
answer
61
views
Xcode 12.5 NSCoding issue with SpriteKit/GameplayKit
I'm working on application using SpriteKit and I'm having trouble with NSCoding on a particular object (a GKComponent object). I'm using Swift 4.0 and iOS 11 in Build Settings. The application always ...
0
votes
2
answers
141
views
call a method from another class with required init coder
I have a class with a required init coder that I have a method I would like to call from another class. Im unsure how to instantiate this class.
first class I want to call
import UIKit
import ...
0
votes
0
answers
37
views
How to send and receive messages using stompClient Lib in swift iOS?
I want to send message using StompClientLib
import UIKit
import StompClientLib
class ChatsVC: UIViewController {
@IBOutlet weak var chatTblView: UITableView!
@IBOutlet weak var ...
0
votes
0
answers
17
views
Swift4 Double subtraction Wrong
I'm new to swift and am trying to do a very basic subtraction operation with Doubles:
let currDate = Date().timeIntervalSince1970
let range = Double(periodoGraph * 60 * 60) // periodoGraph = 72
let ...
1
vote
0
answers
158
views
Edit saved data in Core data using swift
I am building an app in swift which has takes user details like Name, age, gender, picture, About me. I am saving all the data in core data and and displaying it in tableView. It also has a swipe to ...
1
vote
2
answers
195
views
Reload tableview without scroll
I am new to swift
I want to reload my tableview so I used tableviewName.reloadData()
After this the table view is reloaded and scrolled a bit upwards but I want to stay where it is
Here is the code
...
0
votes
1
answer
122
views
Refresh Bearer Token and resume current API
I need to resume my WebService if my bearer token expire by http code 401 ,
below is my code.
When a 401 error occurs that means the Access Token has expired and I need to send a Refresh Token over ...
-2
votes
1
answer
114
views
Programmatically emptying UIStackView
I have a fairly simple code which, upon clicking a button, adds a randomly colored UIView to a UIStackView, and upon a different button click, removes a random UIView from the UIStackView.
Here's the ...
1
vote
3
answers
394
views
Array with multiple values per index?
I'm learning swift, and I do the sololearn course to get some knowledge, but I bumped into something that I don't understand.
It is about modifying an array's values. The questionable part states the ...
12
votes
1
answer
337
views
Tapping on a video in a table view cell to open it in a view controller
tl;dr I'm trying to recreate this in the Twitter app: https://i.imgur.com/173CVyM.mp4
As you can see, Twitter plays a video in the feed (table view cell) and when the video is tapped, the video ...
1
vote
1
answer
70
views
Text View placeholder being cut off
I have a custom UITextView that shows a placeholder, like so:
extension UITextView {
private class PlaceholderLabel: UILabel { }
private var placeholderLabel: PlaceholderLabel {
if ...
-2
votes
1
answer
71
views
Xcode Storyboard file displaying source control diff interface
When I click on my Storyboard file, I can't see the UI I made.
It's showing some code instead of my UI.
How can I see my Storyboard user interface?
0
votes
1
answer
111
views
Confused about async block inside loop
I want to print the data only after executing all loops inside the closure block, since I don't know how to use dispatch group exactly. I have tried in several ways.
What am I doing wrong here?
...
1
vote
1
answer
400
views
Replace all line breaks with a space in a UITextView
I have a UITextView. I want to disable all line breaks in the text view, whether they're typed manually or if the user pastes text that contains line breaks, and replace each line break with a space (&...
0
votes
1
answer
36
views
Smaller button over a big button in swift
I am new to swift and iOS development. I have created a scroll view with table view cells and image views inside cells. Each Image view has a button with same constraints. I have a fixed button in the ...
2
votes
1
answer
548
views
How to change UITextField size inside UIViewRepresentable in SwiftUI
I want to make a simple custom UITextField and I can't figure out how to set its height.
The problem is the UITextField expands to fill parent, and I realise I can set .frame() modifier on the ...
0
votes
0
answers
72
views
Click button to add additional text fields not working
I have a poll system where users are able to create polls. Each poll must have at least two options, with the ability to add up to four.
Right now, I have a collection view cell for each text field, ...
1
vote
2
answers
71
views
Deinit not calling - Cannot find why something is retaining (code provided)
I have discovered that my UIViewcontroller is not calling deinit() under the following scenario.
I am using this code extension to make my life easier by adding tap gesture recognizers.
https://gist....
0
votes
0
answers
46
views
Scheduled IOS local notifications repeat every minute
I have an IOS app that schedules a local notification on the day the app is opened, and every day at roughly the same time for the next 7 days. What happens is each notification is repeated the number ...
0
votes
2
answers
481
views
Adding time from string into date object swift
I have a time coming from service in string form like so "12:30 PM".
I am able to get this time but I want to add this time in current date. like so
31/3/2021 12:30 PM
The current date is ...
0
votes
0
answers
159
views
Decoding Base64 in Swift Returns nil
I have been trying to implement Coinbase API in my application that is built using swift 5 and xcode. Whenever I try to convert this base64 encoded data to Normal string, it returns nil.
Here is the ...
-1
votes
1
answer
248
views
SwiftUI simple Pop-Up Alert from a function in a class
I am a little confused, I try to display a pop-up in my View when my function is true otherwise continue but I do not understand how to do it I am lost between the different ways of doing. I tried ...
0
votes
0
answers
34
views
What is the safest way to create the coredata stack
In order to initiate the coredata stack in app delegate is not recommended as it will create issue in a multi threaded environment. Therefore, I created a separate class for coredata stack and then a ...
0
votes
0
answers
29
views
Change Button image from view controller inside custom header cell
I have a VC that is UICollectionView that has header. This header is a custom cell, and inside that cell there is an button with image which I need to change based on info from API or user tap.
In ...
2
votes
1
answer
818
views
Swift base64 decode non alphabetic and non utf-8 strings
Is it possible to correctly decode using Swift language base64 encoded string which contains a string in non-utf8 encoding (ie. Windows-1252 or ISO-8859-1)?
Every snippet of code that can be found ...
0
votes
3
answers
156
views
How to give size to table view to XIB
I am new to iOS practicing XIB I have created an XIB for a cell
Now When I resize it from here I automatically change its behaviour in tableview I want to give this XIB with as 100% of tableview. I ...
0
votes
1
answer
294
views
Swift - Problem with scrollview (Need to print when dragging down)
I am testing the swiping controller/gesture from Jake Spracher with his SnapchatSwipeView (https://github.com/jakespracher/Snapchat-Swipe-View )
I have setup a topVC,leftVC,rightVC and middleVC(the ...
1
vote
1
answer
584
views
Safe JSON Decoding. Still getting Key not found: No value associated with key'
IMGUR image search returns json:
{"data": [{
"title": "Family :)",
"images": [{
"title": null,
...
0
votes
2
answers
171
views
How to create model object for Imgur JSON | Swift
Imgur image search response has following structure (simplified) :
{ "data": [ {"title" : "Kittens",
"images" : [ { "title" : "&...
0
votes
1
answer
255
views
Beginner stuck with a problem with NSScreen.screens
I'm a beginner with swift and I'm learning as I go with a project for myself. Right now, I'm trying to make a "kiosk mode" window appear that maximizes to fill the entire screen while the ...
1
vote
0
answers
74
views
Navigation controller is nil after switching the rootviewcontroller
I have to change / switch rootviewcontroller to user home page when login is success.
But when I change rootviewcontroller here I can't navigate to another page from buttons inside home view ...
0
votes
1
answer
248
views
Can't initialize crashlytics in iOS
Followed all instructions showed in this video: https://www.youtube.com/watch?v=qFQLG1Hlzis
As well as all instructions that are shown here: https://firebase.google.com/docs/crashlytics/get-started
My ...
-2
votes
1
answer
62
views
Unable to Extract Data from the Dictionary<String, Any> in swift
I have a Dictionary<String, Any> Data in the following format. I need to extract the values from it.I am unable to extract the values, initially it looked to me as JSON but it's of type ...