Top "Swift4" questions

Use this tag only for questions directly related to changes in version 4 of Apple's Swift programming language.

Overlapping accesses to 'urlComponents', but modification requires exclusive access

I am trying to use the Lyft API with iOS 11 and Swift 4, and am receiving an error on the second …

swift swift4 xcode9-beta
init(colorLiteralRed:,green:,blue:,alpha:) deprecated in Swift 4

let startingColorOfGradient = UIColor(colorLiteralRed: 255/255, green: 255/255, blue: 255/255, alpha: 1.0).cgColor let endingColorOFGradient = UIColor(colorLiteralRed: 251/255, green: 247/255, blue: 234/255, alpha: 1.0).cgColor let gradient: CAGradientLayer = CAGradientLayer() …

uicolor swift4
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 …

barcode avcapturesession ios11 swift4 xcode9-beta
Codable enum with default case in Swift 4

I have defined an enum as follows: enum Type: String, Codable { case text = "text" case image = "image" case document = "document" …

ios swift enums swift4 codable
iOS Swift Decodable: Error: Cannot invoke initializer for type with no arguments

I'm getting error in initialising a struct, please see the screenshot attached below. After debugging I found that including review …

ios swift swift4 decodable
How to conform UIImage to Codable?

Swift 4 has Codable and it's awesome. But UIImage does not conform to it by default. How can we do that? …

uiimage swift4 codable
Taking photo with custom camera iOS 11.0 Swift 4. Update error

I have a custom camera in my app and it worked fine, but after the new update I am getting …

swift xcode camera swift4 xcode9
Swift Codable Decode Manually Optional Variable

I have the following code: import Foundation let jsonData = """ [ {"firstname": "Tom", "lastname": "Smith", "age": "28"}, {"firstname": "Bob", "lastname": "Smith"} ] """.data(using: .…

swift swift4 codable
Swift Codable expected to decode Dictionary<String, Any>but found a string/data instead

I have been working with the Codable protocol Here is my JSON file : { "Adress":[ ], "Object":[ { "next-date":"2017-10-30T11:00:00Z", "…

json swift swift4 codable
How to fix "'@IBInspectable' attribute is meaningless on a property that cannot be represented in Objective-C" warning

In Xcode 9 and Swift 4 I always get this warning for some IBInspectable properties: @IBDesignable public class CircularIndicator: UIView { // this has …

swift xcode swift4 xcode9-beta