The implementation and invocation methods of the unique enumeration functions of Swift 2.0

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.