前端之家收集整理的这篇文章主要介绍了
Swift教程之typealias取代OC的typedef,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
//MARK:-------swift中的typedef--------------
//使用 关键字定义类型别名,类似typedef
typealias NSInteger = Int
var value : NSInteger = 45
value = 12
print(value);
//MARK:-------String--------------
let label = "The width is "
let width = 94
var widthLabel = label + String(width) //Swift不支持隐式类型转换,需要显式类型转换
widthLabel += "!"
print(widthLabel)
//Swift使用\(item)的形式进行字符串格式化
let apples = 3
let oranges = 5
let appleSummary = "I have \(apples) apples."
let fruitSummary = "I have \(apples + oranges) pieces of fruit."
原文链接:https://www.f2er.com/swift/326693.html