gpt4 book ai didi

xcode - Xcode 8.1 swift 3永远需要编译此代码

转载 作者:行者123 更新时间:2023-12-02 10:45:15 25 4
gpt4 key购买 nike

我在以前使用swift 2.3的项目中有此类。当我将项目迁移到Swift 3时,xcode花费了很多时间进行编译,而我发现它停留在此类中。由于此类,我无法构建整个项目。有没有一种方法可以修改此类,以便可以构建项目,因此Xcode花费了很多时间来编译这段代码。如果我从MyClass中删除了几个属性,Xcode将迅速重新编译。有人对如何解决这个问题有任何想法吗?

import Foundation

class MyClass: NSObject {

var id: String = ""
var uid: String = ""
var uname: String = ""
var fname: String = ""
var txt: String = ""
var hay: Float = 0
var flag = false
var long: Double = 0
var lat: Double = 0
var altitude: Double = 0
var course: Double = 0
var speed: Double = 0
var lname: String = ""
var city: String = ""
var country: String = ""
var sublocal: String = ""
var subarea: String = ""
var thumb: String = ""
var trash = false
var date: Double = 0
var updated: Double = 0
var furl: String = ""

func toAnyObject() -> Any {
return [
"id": id,
"uid": uid,
"uname": uname,
"fname": fname,
"txt": txt,
"hay": hay,
"flag": flag,
"long": long,
"lat": lat,
"altitude": altitude,
"course": course,
"speed": speed,
"lname": lname,
"city": city,
"country": country,
"sublocal": sublocal,
"trash": trash,
"subarea": subarea,
"thumb": thumb,
"date": date,
"updated": updated,
"furl": furl
]
}
}

最佳答案

不用大词典字面量重写。所以:

func toAnyObject() -> Any {
var d = [String:Any]()
d["id"] = id
d["uid"] = uid
// ... and so on ...
return d
}

关于xcode - Xcode 8.1 swift 3永远需要编译此代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40440977/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com