First,//Enumerate network access Errors//swiftfunctions and properties can be defined in enumerations
PrivateenumGffnetworkerror: Int {
Case Emptydataerror =-1
Case Emptytokenerror =-2
//Error Description
Private var errordescription:String{
Switch Self {
Case . Emptydataerror:return"Empty Data"
Case . Emptytokenerror:return"Tokenis empty"
}
}
//returns the corresponding error based on the enumeration type
Private func errror () Nserror {
return Nserror(Domain: Gfferrordomainname, Code:RawValue, UserInfo: [Gfferrordomainname:errordescription])
}}Second,enumGffclass: String {
Case Emptyname = "Emptyname"
Case FullName = "FullName"
Static func getName (Type: Bool), (String) {
return type = = false ? Gffclass.Emptyname.RawValue: Gffclass.FullName.RawValue
}}
the method that invokes the function in the enumeration (static modified enumeration functions, equivalent to class methods, non-decorated enumeration functions, equivalent to class object methods)Gffnetworkerror.Emptydataerror.errror ()Let name:string = Gffclass.GetName (True)
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The implementation and invocation methods of the unique enumeration functions of Swift 2.0