9月25日 xcode 升級7.0 ?iOS升9 swift升2以后
1艺晴、xcode自動添加了一些try catch代碼
2嗜价、一些舊方法被廢除?
? ? ? stringByAppendingPathComponent:替換為URLByAppendingPathComponent
/*let docsPath = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)[0]
let imageDirPath = docsPath.stringByAppendingPathComponent("SwiftDataImages")
let fullPath = imageDirPath.stringByAppendingPathComponent(path)
if !NSFileManager.defaultManager().fileExistsAtPath(fullPath) {
print("SwiftData Error -> Invalid image ID provided")
return nil
}*/
let manager = NSFileManager.defaultManager()
var urlForDoc = try?manager.URLForDirectory(NSSearchPathDirectory.DocumentDirectory, inDomain: NSSearchPathDomainMask.UserDomainMask, appropriateForURL: nil, create: true)
let imageDirPath = urlForDoc!.URLByAppendingPathComponent("SwiftDataImages")
let fullPath = imageDirPath.URLByAppendingPathComponent(path)
if !manager.fileExistsAtPath(fullPath.path!){
print("SwiftData Error -> Invalid image ID provided")
return nil
}
網(wǎng)絡(luò)請求方面 NSURLConnection替換為NSURLSeesion
網(wǎng)絡(luò)請求仍然失斎鱿: The resource could not be loaded because the App Transport Security?
原因是iOS9引入新特性ATS (App Transport Security)鏈接ATS? 要求APP內(nèi)訪問的網(wǎng)絡(luò)必須使用https 根本解決辦法就是修改協(xié)議 臨時訪問http 的方法:1荣病、在info.plist添加NSAppTransportSecurity類型Dictionary 2坐慰、在NSAppTransportSecurity下添加NSAllowsArbitraryLoads類型Boolean馁蒂,值設(shè)置為YES