Skip to content

Instantly share code, notes, and snippets.

@simplytunde
Last active August 29, 2015 14:12
Show Gist options
  • Save simplytunde/a6a741f9d90af5671a38 to your computer and use it in GitHub Desktop.
Save simplytunde/a6a741f9d90af5671a38 to your computer and use it in GitHub Desktop.
Swift: Key Notes
  • You can only use public swift classes or those marked with @objc in objective file.
  • The public properties & method will be available to you
  • The internal properties & method will only be available if objective--c bridging file is present.
  • only private marked with @objc,@IBAction or @IBOutlet will be accessible
  • If you mark a class public(unlike private and internal), it members will have a default access of internal.
  • Tuple type assume access of its most restrictive type.
  • Function assume access of its most restrictive parameter type or return type.
  • access type of associate type in an enum must be at least that of the whole enum. The example below is an error because associated type has overall access of private while the enum has default internal access. Since private is less than internal, its an error. The associated type must either be public or internal
enum  ENUMERATION{
      case A(PrivateClass,PubicClass)
}
  • For a variable, you can use the access specifier to specify if only set or get should have that access
class A{
  private(set) var name:String
}
  • You can specify access type for init except the required init.
  • If a protocol has public type, its require get public access type unlike classes.
  • If a internal protcol conform to private protocol, it becomes private.
  • A private typealias can alias private,internal & public unlike public typealias which can only alias public.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment