app修改纪录

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容