SwiftCommon之String字符串

概述

String字符串的常用方法。

SCString

import Foundation

// MARK: - 字符串
extension String {
    
    /**
    字符串截取,从头开始
    
    :param: endIndex 从头开始截取,到哪一个索引号结束
    
    :returns: 截取后的字符串
    */
    func subString(let endIndex:Int)->String{
        
        let startIndex = self.startIndex
        let index = advance(startIndex, endIndex)
        return self.substringToIndex(index)
    }
    
    
    /// 字符串的长度
    var length: Int {
        return count(self)
    }
    
}

Git地址

http://devonios.com/go/swiftcommon

tips:

本文由wp2blog导入,原文链接:http://devonios.com/scstring.html

评论

暂无评论