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
1 answer

String to WritableKeyPath

How do I convert a String to a WritableKeyPath? Something like: struct MyStruct { let x: Bool } let string = "x" let myStruct = MyStruct(x: false) let x = myStruct[keyPath: keyPathFromString(string)!]
Rodrigo Ruiz
  • 4,248
  • 6
  • 43
  • 75
2
votes
1 answer

Swift : Can I use home and work locations using MapKit?

Everyone knows that Maps app can detect your home and work location and it shows you with "maps destination" feature. I am just wondering how it gets our specific location like work and home. Is it because we are stable on some places and it figures…
jorjj
  • 1,479
  • 4
  • 20
  • 36
2
votes
2 answers

Migration from Swift 3 to Swift 4 Navigation Bar broken interface

I have migrated my app from Swift 3.1 to Swift 4.0 (Xcode 8.3.3 to Xcode 9.0) and some part of my interface is broken now. Navigation Bar of Navigation controller is complete mess. Please, look at screenshot: There are 3 elements: left Netfnet…
Alex
  • 1,038
  • 2
  • 12
  • 32
2
votes
0 answers

WKWebView delegate method changes

I am working on migrating UIWebView to WKWebView. I have changed all the Delegate methods. I need WKWebView delegate methods equal to below UIWebView delegate method. I have written below method in UIWebView. Help me to change below code into…
Siva
  • 1,848
  • 2
  • 23
  • 40
2
votes
1 answer

MKMapView doesn't load map and show yellow background

Once I start the app it should load the map of the city you are in. It worked perfectly in IOS 9-10. Since iOS 11 map started to act strangely. Now when you start the app it shows yellow map. If I click home button, wait 3-5 sec and go back into the…
Jared_M
  • 547
  • 1
  • 5
  • 13
2
votes
1 answer

Proper way to end an Async process

So I have this code: @IBAction func onStart(_ sender: Any) { DispatchQueue(label: "SyncQueue").async{ for i in 0..
SquareBox
  • 823
  • 1
  • 10
  • 22
2
votes
1 answer

UIDatePicker, display Full Date with YEAR and time

Can you have a UIDatePicker display the day, month, year, and time on the DatePicker, or do I need to make my own custom UIPickerView? i.e. Mon Nov 12 2000 5 20 AM Currently the date picker with .datePickerMode set to .dateTime shows Mon Nov 12 5 20…
Jevon718
  • 354
  • 4
  • 10
2
votes
1 answer

Cannot Assign Value Of Type 'CGColor' To UIColor

I want to change the default blue of the back button. I have created my own color, which works completely fine with my text fields. Whenever I try to use this code to change the back button with my custom color, it doesn't work and I get the error.…
Deborah P.
  • 31
  • 4
2
votes
1 answer

Trying to mimic the Mail.app compose animation keeping a layer in view

I have been trying for a while but I cannot figure out how to create a Compose animation seen in the iOS 10+ when you can drag the new composed email down, then it stays on the bottom and the rest of the app is normally accessed, then when you tap…
Ivan Cantarino
  • 3,058
  • 4
  • 34
  • 73
2
votes
1 answer

NSRect.fill() not working with clear colors on Xcode 9 Swift 4

Swift 4 has a new NSRect.fill() function to replace NSRectFill(). When attempting to clear a bitmap using NSColor.clear.setFill(), the bitmap remains unchanged using NSRect.fill(). A workaround is to use NSRect.fill(using:) and specifying…
Dave
  • 145
  • 1
  • 9
2
votes
1 answer

Swift 4 - Multiple inheritance from classes 'NSObject' and 'UICollectionViewFlowLayout'

I am trying to programatically size the collection cell to be the width of the frame, however, the cell size doesn't change when I run the app. Is this the right function to call for Swift 4 and Xcode 9? import UIKit class SettingsLauncher:…
Niall Kiddle
  • 1,477
  • 1
  • 16
  • 35
2
votes
1 answer

How do I parse a JSON object that has type-dependent sub-objects, in Swift?

I have the following JSON object: [{ "type": "foo", "props": { "word": "hello" } }, { "type": "bar", "props": { "number": 42 } }] Depending on the type stored in type, the object in props has different keys.…
Morpheu5
  • 2,610
  • 6
  • 39
  • 72
2
votes
0 answers

Slackbot written in Swift 4 deployed on Heroku

I wrote a Slackbot with SlackKit and Swift 4.0. I followed a very simple and easy to understand tutorial from Peter Zignego He deployed his Bot at Heroku So first issue that appears was that I use a array extension which gives me a random item from…
2
votes
1 answer

Error using Self in generic function where clause

I am running into an issue when I try to use Self as part of a where clause in a generic function which is part of a protocol. For example, say I have this protocol and this generic function defined: protocol Animal { associatedtype FoodSource …
sak
  • 2,612
  • 24
  • 55
2
votes
1 answer

Xcode 9/Swift 4 AVCaptureMetadataOutput setMetadataObjectTypes use availableMetadataObjectTypes

There seems to be a lot of issues similar to what I am experiencing: AVmetadata changes with swift 4 xcode 9 AVCaptureMetadataOutput setMetadataObjectTypes unsupported type found And there is an Apple bug that deals with…
addzo
  • 845
  • 3
  • 13
  • 37