将String转化为NSString再截取:
var s="1234567890"
var ns1=(s as NSString).substring(from: 5)
var ns2=(s as NSString).substring(to: 4)
var ns3=(s as NSString).substring(with: NSMakeRange(4, 1))
print(ns1)//67890
print(ns2)//1234
print(ns3)//5
获取字符串的长度:
http://www.cnblogs.com/daxueba-ITdaren/p/6002980.html