Top "Swift4" questions

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

UIApplication.registerForRemoteNotifications() must be called from main thread only

Xcode 9 (iOS 11) showing me an error/warning while registering for Push (remote) notification. Here is error message And here is …

ios swift push-notification swift4 unusernotificationcenter
Xcode 9 : Module compiled with Swift 3.1 cannot be imported in Swift 4.0

After updating to Xcode 9, I tried to build one of my projects. I use the FacebookLogin pod. I have a …

ios cocoapods facebook-login xcode9-beta swift4
Swift 4 Conversion error - NSAttributedStringKey: Any

I converted my app recently and I keep getting the error "Cannot convert value of type '[String : Any]' …

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

json swift encoding swift4 codable
How to get substring with specific ranges in Swift 4?

This is using the example code from the official Swift4 doc let greeting = "Hi there! It's nice to meet you! 👋" …

swift substring swift4
Swift - How to get indexes of filtered items of array

let items: [String] = ["A", "B", "A", "C", "A", "D"] items.whatFunction("A") // -> [0, 2, 4] items.whatFunction("B") // -> [1] Does …

arrays swift swift3 swift4
Unable to access Swift 4 class from Objective-C: "Property not found on object of type"

Using the latest Xcode 9 beta, I'm seemingly completely unable to access properties on Swift classes. Even odder, I can access …

ios objective-c swift xcode swift4
Cannot convert value of type NSAttributedString.DocumentAttributeKey to .DocumentReadingOptionKey

I found this string extension somewhere on SO that allows me to turn html code into an attributed string: func …

ios swift swift4 nsattributedstringkey
Declarations in extensions cannot override yet error in Swift 4

I have an extension: public extension UIWindow { override public func topMostController()->UIViewController? { ... } } but for my topMostController I get …

ios swift swift-playground swift4
Using Decodable in Swift 4 with Inheritance

Should the use of class inheritance break the Decodability of class. For example, the following code class Server : Codable { var …

swift swift4 codable