swift3

Weird issue during migration from Swift 2 to Swift 3: Initializer has different argument names from those required by protocol

自作多情 提交于 2020-01-03 01:42:13
问题 I'm trying to migrate this (https://github.com/emilwojtaszek/leveldb-swift) project from Swift 2 to Swift 3. I've cleared all 100+ errors during migration except this following one: Initializer 'init(bytes:count:)' has different argument names from those required by protocol 'KeyType' ('init(bytes:length:)') I was struggling to figure out the reason for it past couple of hours and getting no clue of what the problem is, any thoughts? P.S. Here is the link to project with current state of

Error deleting contents in directory - Domain=NSCocoaErrorDomain Code=4 | Domain=NSPOSIXErrorDomain Code=2 “No such file or directory”

谁都会走 提交于 2020-01-02 19:28:20
问题 How can I fix the following errors when running the code below? I already searched in SO but can't find anything for Swift 3. // Delete all files in given directory let path = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as String let dataPath = NSURL(fileURLWithPath: path) if let enumerator = FileManager.default.enumerator(atPath: dataPath.path!) { while let fileName = enumerator.nextObject() as? String { do { try FileManager.default.removeItem(atPath: "\

PFObject values may not have class: _SwiftValue

吃可爱长大的小学妹 提交于 2020-01-02 15:05:59
问题 We are trying out Parse server , and we have never used Parse SDK before. As part of learning we tried Facebook login with Parse , that worked good. Next we wanted to save the retrieved user information and we are stuck at saving the Profile picture . The Code let pictureURL = "https://graph.facebook.com/\(facebookID)/picture?type=large&return_ssl_resources=1" let imageData = NSData.init(contentsOf: NSURL(string: pictureURL) as! URL) let picture = PFFile(data: imageData! as Data) PFUser

How can I use Swift 2.2 on Xcode8?

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-02 11:01:58
问题 I had a project on Swift2.3 and XCode7 . It worked well. When I have updated it to XCode8 and Swift3 the project does not show anything on the emulator so I decided to use, at least by the moment, Swift2.2 on Xcode8 (I have a copy of the project in Swift2.2 ) but it gives to me the following error: “Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift

How can I use Swift 2.2 on Xcode8?

穿精又带淫゛_ 提交于 2020-01-02 10:59:28
问题 I had a project on Swift2.3 and XCode7 . It worked well. When I have updated it to XCode8 and Swift3 the project does not show anything on the emulator so I decided to use, at least by the moment, Swift2.2 on Xcode8 (I have a copy of the project in Swift2.2 ) but it gives to me the following error: “Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift

How can I use NSVisualEffectView to blend window with background

时间秒杀一切 提交于 2020-01-02 08:02:25
问题 There seem to be a bunch of questions on this for old versions of Swift/Xcode, but for some reason it hasn't been working with the latest update. I created a NSVisualEffectView, blurryView, and added the subview to my main view: class ViewController: NSViewController { @IBOutlet weak var blurryView: NSVisualEffectView! override func viewDidLoad() { super.viewDidLoad() //background styling blurryView.wantsLayer = true blurryView.blendingMode = NSVisualEffectBlendingMode.behindWindow blurryView

How can I use NSVisualEffectView to blend window with background

旧街凉风 提交于 2020-01-02 08:02:21
问题 There seem to be a bunch of questions on this for old versions of Swift/Xcode, but for some reason it hasn't been working with the latest update. I created a NSVisualEffectView, blurryView, and added the subview to my main view: class ViewController: NSViewController { @IBOutlet weak var blurryView: NSVisualEffectView! override func viewDidLoad() { super.viewDidLoad() //background styling blurryView.wantsLayer = true blurryView.blendingMode = NSVisualEffectBlendingMode.behindWindow blurryView

Xcode 8 does not auto-complete for init methods

大兔子大兔子 提交于 2020-01-02 06:59:29
问题 I am having trouble getting Xcode 8 with Swift 3 to auto-complete common initialization methods, and was wondering if there is anything I could do to fix the situation. Specifically, take something like: let jsonString = String(data: jsonData, encoding: .utf8) The initialization method String(data:, encoding:) will not populate. Demo Video 回答1: I find it useful to type the actual word .init before asking for code completion. Then later, I take it back out again. Note that Xcode is very choosy

Swift 3 type inference confusion

寵の児 提交于 2020-01-02 05:48:08
问题 I'm using macOS. I have the following code. The only difference between 1, 2, 3, 4 and 5 is what is in the 'metrics' parameter. let a = 20 let met = ["a": a] // 1: This compiles. _ = NSLayoutConstraint.constraints(withVisualFormat: "|[v1(a)]|", metrics: ["a": 20], views: ["v1": v1]) // 2: This fails with "Cannot convert value of type 'Int' to expected dictionary value type 'NSNumber'". _ = NSLayoutConstraint.constraints(withVisualFormat: "|[v1(a)]|", metrics: ["a": a], views: ["v1": v1]) // 3

How to pre load database in core data using swift 3 xcode 8

徘徊边缘 提交于 2020-01-02 05:36:11
问题 I have a database with data and I want to preload that in application. Before swift 3 it works and I have followed this tutorial : http://www.appcoda.com/core-data-preload-sqlite-database/ But how to load same database for swift 3? As NSPersistentContainer is introduced how can I load .sqlite file which is in my project? 回答1: Actually the default path where database was created is changed in swift 3 . So now the code will look like : func preloadDBData() { let sqlitePath = Bundle.main.path