Bra*_*ley 9 macos casting class ios swift
我有,
struct S {}
Run Code Online (Sandbox Code Playgroud)
随着,
func y (x: S) -> AnyObject {}
Run Code Online (Sandbox Code Playgroud)
在Swift 2中,是否有可能在y()中,
return x
Run Code Online (Sandbox Code Playgroud)
我目前的代码:
struct S {let value: Int = 0}
let x = S()
func y(x: S) -> AnyObject {return x}
Run Code Online (Sandbox Code Playgroud)
产生以下错误:
'S'类型的返回表达式不符合'AnyObject'类型
有没有办法缓解这种情况?