Swift is a new programming language for iOS and OS X apps that builds on the best of C and Objective-C, without the constraints of C compatibility.
Swift adopts safe programming patterns and adds modern features to make programming easier, more flexible and more fun.
Swift’s clean slate, backed by the mature and much-loved Cocoa and Cocoa Touch frameworks, is an opportunity to imagine how software development works.
Swift is the first industrial-quality systems programming language that is as expressive and enjoyable as a scripting language.
letlabel="The width is "letwidth=94letwidth=label+String(width)
字符串格式化
Swift使用\(item)的形式进行字符串格式化:
1234
letapples=3letoranges=5letappleSummary="I have \(apples) apples."letappleSummary="I have \(apples + oranges) pieces of fruit."
数组和字典
Swift使用[]操作符声明数组(array)和字典(dictionary):
12345678
varshoppingList=["catfish","water","tulips","blue paint"]shoppingList[1]="bottle of water"varoccupations=["Malcolm":"Captain","Kaylee":"Mechanic",]occupations["Jayne"]="Public Relations"
请发表评论