美文网首页
app修改纪录

app修改纪录

作者: 这里有一个空格 | 来源:发表于2015-09-25 16:59 被阅读36次

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

}

网络请求方面 NSURLConnection替换为NSURLSeesion

网络请求仍然失败: The resource could not be loaded because the App Transport Security 

原因是iOS9引入新特性ATS (App Transport Security)链接ATS  要求APP内访问的网络必须使用https 根本解决办法就是修改协议 临时访问http 的方法:1、在info.plist添加NSAppTransportSecurity类型Dictionary 2、在NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,值设置为YES

相关文章

网友评论

      本文标题:app修改纪录

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