Language Reference

Language Reference


1.关键字

Keywords used in declarations: class, deinit, enum, extension, func, import, init, internal, let, operator, private, protocol, public, static, struct, subscript, typealias, and var.


Keywords used in statements: break, case, continue, default, do, else, fallthrough, for, if, in, return, switch, where, and while.


Keywords used in expressions and types: as, dynamicType, false, is, nil, self, Self, super, true, __COLUMN__, __FILE__, __FUNCTION__, and __LINE__.


Keywords reserved in particular contexts: associativity, convenience, dynamic, didSet, final, get, infix, inout, lazy, left, mutating, none, nonmutating, optional, override, postfix, precedence, prefix, Protocol, required, right, set, Type, unowned, weak and willSet. Outside the context in which they appear in the grammar, they can be used as identifiers.


2.Declaration

swift中的定义和声明是一体的。声明即定义。


3.Attributes

@assignment 重载混合赋值运算符

@class_protocol 限制协议只允许类继承

@noreturn 放置在函数,类中的方法的前面表示该函数没有返回值

@NSCopying

@NSManaged

@objc 声明该类型可以用于ObjectiveC,比如非嵌套类,协议,属性,方法等

@UIApplicationMain 放在类前面,代表该类是app的代理。


你可能感兴趣的:(Language Reference)