It seems like there is some issue with the auto-suggestion in Xcode-10. I just tried with the below example and found that suggestion were not appearing for default initialisation. However if you write and compile, it will work.
let newObj = MyStruct(aa: "1", bb: "2")
Even if you want to debug it more, use init
method, it will show auto-suggestion as well:
let newObj1 = MyStruct.init(aa: "A", bb: "B")
MyStruct.swift
import Foundation
struct MyStruct {
var aa = ""
var bb = ""
}
func test() {
let myStruct = MyStruct(aa: "", bb: "")
print(myStruct)
}
ViewController.swift
import UIKit
override func viewDidLoad() {
super.viewDidLoad()
let newObj = MyStruct(aa: "1", bb: "2")
print(newObj)
let newObj1 = MyStruct.init(aa: "A", bb: "B")
print(newObj1)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.