Top "Swift4" questions

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

Swift 4: Cannot convert value of type '(_) -> ()' to expected argument type '() -> ()' or Argument passed to call that takes no arguments

Using XCode 9, Beta 3. Swift 4. statsView.createButton("Button name") { [weak self] Void in //stuff stuff self?.doSomething() } I get hundreds of …

swift closures swift4
Swift 4 Codable; How to decode object with single root-level key

I'm using the Swift 4 Codable protocol with JSON data. My data is formatted such that there is a single key …

json swift deserialization swift4 codable
Swift 4 Codable Array's

So I have an API route that returns a JSON array of objects. For example: [ {"firstname": "Tom", "lastname": "Smith", "age": 31}, {"…

swift swift4 codable
Using codable with value that is sometimes an Int and other times a String

I have an API that will sometimes return a specific key value (in this case id) in the JSON as …

json swift swift4 codable
It gives errors when using Swift Static library with Objective-C project

I need to make swift static library for my requirement. I made swift static library which uses swift and Obj-c …

ios swift static-libraries swift4 xcode9.3
Swift 4 Decodable with keys not known until decoding time

How does the Swift 4 Decodable protocol cope with a dictionary containing a key whose name is not known until runtime? …

json swift4 decodable
non-nominal type X does not support explicit initialization

I'm trying to understand what I'm doing wrong with generics in swift. I created this sample playground import UIKit public …

ios swift xcode generics swift4
Swift Decodable Optional Key

(This is a follow-up from this question: Using Decodable protocol with multiples keys.) I have the following Swift code: let …

ios json swift swift4 codable
Adjust position of bar button item when using large titles with iOS 11

I am using the large title navbar with iOS 11, but when I add a bar button item it looks weird …

ios swift ios11 swift4
Migration to Swift 4 from Swift 3.2 giving "failed to import bridging header " error

As apple has released Xcode 9 beta version with Swift 4.0 support. I have been trying to upgrade my code to Swift 4.0 …

ios swift4 xcode9