swift format string

作者: 微微笑的蜗牛 | 来源:发表于2015-11-17 20:46 被阅读1614次

    //: Playground - noun: a place where people can play

    importUIKit

    funcformatString1(format:String,_args:CVarArgType...) {

    formatString1_inner(format,getVaList(args))

    }

    // NSString format

    funcformatString1_inner(format:String,_args:CVaListPointer) {

    letstring =NSString(format: format, arguments: args)

    print(string)

    }

    funcformatString2(format:String,_args:CVarArgType...) {

    formatString2_inner(format, args);

    }

    // String format

    funcformatString2_inner(format:String,_args:[CVarArgType]) {

    letstring =String(format: format, arguments: args)

    print(string)

    }

    formatString1("formatString1%d",1)

    formatString2("formatString2%d",2)

    相关文章

      网友评论

        本文标题:swift format string

        本文链接:https://www.haomeiwen.com/subject/rhxlhttx.html