Classes and structs have a lot in common:
Defining properties to store data
Define method Execution function handling
Define subscript to access their values by subscript
Initialize their state
Extend its functionality with extensions (Extension)
Compliance Agreement (PROTOCOL). The protocol provides a specific standard
Function
Analogy structure multi-out function:
can inherit another class
You can check the type of the execution period object
destructor Frees resources
reference count agrees that a class instance has multiple references
definition of class and struct body
define classes and struct bodies:
Class SomeClass {//class definition goes here} struct Somestructure {//Structure definition goes here}
Instance:
struct Resolution {var width= 0 var height =0} class Videomode {var Resolution = Resolution () var interlaced =falsevarfr Amerate = 0.0 var name:string?}
Instantiation of classes and struct bodies
struct Resolution {var width= 0 var height =0}class videomode {var Resolution = Resolution () var interlaced =falsevarfram Erate = 0.0var name:string?}let someresolution= Resolution ()//let someresolution = Resolution (width:10,height:20) Let somevideomode= Videomode ()
Swift Exchange Discussion Forum Forum: http://www.cocoagame.net
Welcome to add Swift Technology Group: 362298485
Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.
Swift Classes and structures