我试图在我用swift编写的类上使用NSCoding协议,但似乎无法弄清楚为什么当我实现所需的方法时编译器抱怨它"不符合协议NSCoding":
class ServerInfo: NSObject, NSCoding {
var username = ""
var password = ""
var domain = ""
var location = ""
var serverFQDN = ""
var serverID = ""
override init() {
}
init(coder aDecoder: NSCoder!) {
self.username = aDecoder.decodeObjectForKey("username") as NSString
self.password = aDecoder.decodeObjectForKey("password") as NSString
self.domain = aDecoder.decodeObjectForKey("domain") as NSString
self.location = aDecoder.decodeObjectForKey("location") as NSString
self.serverFQDN = aDecoder.decodeObjectForKey("serverFQDN") as NSString
self.serverID = aDecoder.decodeObjectForKey("serverID") as NSString
}
func encodeWithCoder(_aCoder: NSCoder!) {
_aCoder.encodeObject(self.username, forKey: "username")
_aCoder.encodeObject(self.password, forKey: "password")
_aCoder.encodeObject(self.domain, …Run Code Online (Sandbox Code Playgroud) 我正在使用GUI,但我遇到了一个问题.如果我将按钮,标签或其他窗口小部件设置为具有背景颜色,则该窗口小部件的工具提示也采用相同的背景颜色.我尝试专门编辑工具提示的样式表并设置不同的背景颜色,但它不起作用.我也尝试编辑窗口小部件的调色板,但更改工具提示背景或文本的颜色方案也不起作用.还有其他方法可以做到这一点吗?我想在我的所有工具提示之间保持一致.
谢谢!