id和instancetype類(lèi)型在swift中的轉(zhuǎn)換
+(id)buttonWithType:(UIButtonType)buttonType
class func buttonWithType(buttonType: UIButtonType)-> AnyObject!
調(diào)用var button = UIButton.buttonWithType(UIButtonType.System)as UIButton
+(instancetype)stringWithCString:(const char *)cString encoding:(NSStringEncoding)enc
class func stringWithCString(cString: CString,encoding enc: UInt)-> Self!
var str = NSString.stringWithCString("foo",encoding: NSUTF8StringEncoding)
var cs = str.UTF8String
只要object-c返回id類(lèi)型的 都要在后面加as 這樣才能保證類(lèi)型一致
轉(zhuǎn)自http://www.myexception.cn/mobile/1746263.html