`
wang_peng1
  • 浏览: 3960080 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

id和instancetype类型在swift中的转换

 
阅读更多
+ (id)buttonWithType:(UIButtonType)buttonType

class func buttonWithType(buttonType: UIButtonType) -> AnyObject!

调用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类型的 都要在后面加as 这样才能保证类型一致

 

分享到:
评论
Global site tag (gtag.js) - Google Analytics