import Foundation //加载网络数据,查找数据的字符串
let dataurl = "http://api.k780.com:88/?app=weather.city&&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json"
var url = NSURL(string: dataurl)
var httpData = NSData(contentsOfURL: url!)
//println(httpData) //输出来都是数字 字节码
var httpstr = NSString(data: httpData!, encoding: NSUTF8StringEncoding)
//println(httpstr) //转为NSString就是 可观的数据了。
let subRange = httpstr?.rangeOfString("玉山")
println("\(subRange!.location) 和 \(subRange!.length)") var findRange = NSMakeRange(subRange!.location-, )
var findStr = httpstr!.substringWithRange(findRange)
println(findStr) //读取本地文件
let path = "/Users/HeYang/Desktop/file.txt"
var findfileStr = String(contentsOfFile: path, encoding: NSUTF8StringEncoding, error: nil)
var nsfindfileStr = NSString(string: findfileStr!)//转为NSString类型
println(nsfindfileStr)
运行结果: