All Questions

78
votes
2answers
16884 views

How can I deal with @objc inference deprecation with #selector() in Swift 4?

I'm trying to convert my project's source code from Swift 3 to Swift 4. One warning Xcode is giving me is about my selectors. For instance, I add a target to a button using a regular selector like th...
25
votes
2answers
6121 views

How do I use custom keys with Swift 4's Decodable protocol?

Swift 4 introduced support for native JSON encoding and decoding via the Decodable protocol. How do I use custom keys for this? E.g., say I have a struct struct Address:Codable { var street:Stri...
317
votes
6answers
47456 views

The use of Swift 3 @objc inference in Swift 4 mode is deprecated?

Briefly, while using Xcode 9 Beta, I have run into the following warning: The use of Swift 3 @objc inference in Swift 4 mode is deprecated. Please address deprecated @objc inference warnings, test...
126
votes
12answers
27710 views

How can I use String slicing subscripts in Swift 4?

I have the following simple code written in Swift 3: let str = "Hello, playground" let index = str.index(of: ",")! let newStr = str.substring(to: index) From Xcode 9 beta 5, I get the following war...
77
votes
11answers
21094 views

navigation bar rightbaritem image-button bug iOS 11

This code works ok in ios10. i get my label and an image button which is the user photo profile, circular round.. ok. but when running xcode 9 ios11 simulator i get it streched out. the button frame h...
9
votes
4answers
1543 views

Swift JSONDecode decoding arrays fails if single element decoding fails

While using Swift4 and Codable protocols I got the following problem - it looks like there is no way to allow JSONDecoder to skip elements in an array. For example, I have following JSON: [ { ...
4
votes
2answers
554 views

How to convert a date string with optional fractional seconds using Codable in Swift4

I am replacing my old JSON parsing code with Swift's Codable and am running into a bit of a snag. I guess it isn't as much a Codable question as it is a DateFormatter question. Start with a struct ...
12
votes
1answers
5041 views

Encode/Decode Array of Types conforming to protocol with JSONEncoder

I'm trying to find the best way to Encode/Decode an array of structs conforming to a swift protocol using the new JSONDecoder/Encoder in Swift 4. I made up a little example to illustrate the problem:...
18
votes
2answers
3037 views

Barcode on swift 4

I'm trying to upgrade mi app to swift 4, but the barcode reader is not working. I have isolated the barcode reader code, and still not working. The camera works but it does not detect the barcode. T...
13
votes
1answers
2567 views

Swift 4 "This class is not key value coding compliant"

I have a Swift library which is heavily reliant on obj.valueForKey() from NSObject. After migrating to Swift 4 I've found that these calls always crash with the error "this class is not key value co...

Previous Next