How do I write things in Swift?
来源:互联网 发布:苹果电脑系统删除软件 编辑:程序博客网 时间:2024/05/19 20:43
How do I write things in Swift?
Classes
class className { func one(){...} ...}
Protocols
protocol protocolName { var one: type ...}
Enums
enum enumName { case memberValue, anotherMemberValue ...}
Structs
struct structName { var one: type ...}
Mutating Properties of a Structure
struct structName { mutating func functionName { var one: type ... }}
Functions
func functionName(parameters) -> returnType { var one: type ...}
Class-Level Functions
class func functionName(parameters) -> returnType { var one: type ...}
Extensions (Categories)
extension classToExtend: optionalProtocol { var one: type ...}
In-out parameters
func functionName(inout parameterName: parameterType) { var one: type ...}
Subscripting
struct structToSubscript { let constantToSubscript = value subscript( parameterName: parameterType ) -> returnType { var one: type ... }}
Closures
{ (parameters) -> returnType in statements }{ (parameters) -> returnType in var one: type ... return result}
Generics
func genericName<T>(parameterName: T) -> returnType { var one: type ...}
Type-Casting
expression as typeexpression as? type
Runtime Type-Checking
expression is type
String interpolation
println("Swift makes me feel \(object) inside")
0 0
- How do I write things in Swift?
- How Do I Declare a Closure in Swift?
- FAQ How do I write to the console from a plug-in?
- How do I write to files using cheerio and request in node?
- How do I debug JavaScript in Safari?
- How do I use Cygwin in Geophysics ?
- How do I install fonts in Fedora
- Write less code, do more things
- How do I get start in QA/Test
- How do I include one DTD (or fragment) in another?
- How do I set breakpoints in modal dialogs?
- How do I create delegates in Objective-C?
- How do I change the default runlevel in Feodra 15?
- How do I disable video thumbnails in Windows 7?
- How do I monitor HTTP communication in Eclipse?
- How do I register a custom filetype in iOS【链接】
- How do I get exception details in XCode 4.6?
- How do I run a 64-bit guest in VirtualBox?
- Android自动化测试框架目标
- isEqual
- activiti 5.19整合modeler在线编辑器
- 轻松制作GIF动画!教你玩转PS时间轴之5个小技巧篇
- UVA 11437 Triangle Fun 几何基础
- How do I write things in Swift?
- Android Design Support Library 的 代码实验——几行代码,让你的 APP 变得花俏
- 物流接口查询
- 玩转Android studio 插件开发、测试、JCenter库发布(1)
- Hbase原理、基本概念、基本架构
- 设计模式(Design Patterns)
- 1》找到接口-浏览器-收集接口
- SQLite 基本操作--查看数据表信息
- VC中L""和_T("")的区别