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.

Swift 4 is the fourth version of the Swift language developed by Apple that was released in 2017. The language is open source and available on Github (see ).

The development of Swift 4 and its goals can be viewed on the Swift Programming Language Evolution repository on GitHub.

5684 questions
2
votes
0 answers

Best way to save a file using NSDocument?

I'm encountering problems saving a document as I can see in the debug area: NSFileVersion tried to tried to add a new generation and failed. Versioned file URL: file:///Users/mike97/Downloads/test%20copy.xml, contents URL:…
Mike97
  • 596
  • 5
  • 20
2
votes
1 answer

Cannot assign value of type '(_) -> ()' to type '((String, String, String, Int) -> ())?'

I have a closure defined like this, public var onLogCompletion:((_ printLog:String,_ fileName:String,_ functionName:String,_ lineNumber:Int) -> ())? = nil Which is updated like this, fileprivate func printerCompletion(printLog:String,…
Hemang
  • 26,840
  • 19
  • 119
  • 186
2
votes
3 answers

.scaleAspectFit - filling the blanks with black color

I have UIImages that I show in a UIImageView. The UIImageView has the contentMode = .scaleAspectFit property. The UIImages show just fine on the UIImageView, but I want to edit the UIImages so that they don't have any blank (transparent) space, and…
Tarek Orfali
  • 73
  • 2
  • 7
2
votes
1 answer

Easiest way to set custom inputview to all textFields globally

I created a custom input view for the App I'm currently working on, I can assign this keyboard to a textField by doing: textField.inputView = myCustomKeyboard as! UIView Now I just want to switch out all inputViews with my custom inputView, is…
Steven B.
  • 1,429
  • 2
  • 19
  • 38
2
votes
1 answer

iOS - Use/pass gesture recognizer for multiple Tableviews or Collectionviews in a View(Swift)

I've got 2 (circular) UICollectionviews in my view, both are functioning but I want to use 1 swipe gesture for both views so when I swipe on the top collectionview, the bottom view should also swipe with the same speed and vice-versa. What would be…
Steven B.
  • 1,429
  • 2
  • 19
  • 38
1
vote
0 answers

Swift 5 very random and hardly identifiable crashes

My crash log from firebase unfortunately doesnt really help me finding a solution to my issue. Crashed: com.apple.main-thread 0 MyApp 0x94d30 PostsAPI.loadNewestPosts(ordering:start:limit:onSuccess:) + 4306505008…
Zash__
  • 293
  • 4
  • 16
1
vote
0 answers

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 to create long length haptic. Like it should last…
Supreet Patil
  • 21
  • 1
  • 4
1
vote
1 answer

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 other way for dynamic pkpass ? or some other way to download…
1
vote
0 answers

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 delete feature. What I want to do is add Swipe to…
Asad
  • 11
  • 2
1
vote
2 answers

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 func searchResult(row: Int, searchText: String,…
Crist
  • 27
  • 7
1
vote
3 answers

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 following: In the following example, the…
Somee
  • 21
  • 6
1
vote
1 answer

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 let label = subviews.compactMap( { $0 as?…
user86516512
  • 445
  • 4
  • 13
1
vote
1 answer

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 (" "). How would I go about doing this? What…
user86516512
  • 445
  • 4
  • 13
1
vote
2 answers

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…
NullHypothesis
  • 4,286
  • 6
  • 37
  • 79
1
vote
0 answers

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 controller. but when I restart the app, it works fine. I…
Jaseel.Dev
  • 730
  • 1
  • 7
  • 19