在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
背景代码量(4万行)
迁移时间(一天左右)
准备
界面用 xib 而不用纯代码
关于第三方库的选择:
知识储备升级
迁移中的问题Any && AnyObject
// Swift 2 var json = [String:AnyObect]() json["key1"] = 1 json["key2"] = "2" // to Swift 3 Step 1 var json = [String:AnyObect]() json["key1"] = 1 as AnyObject? json["key2"] = "2" as AnyObject? // to Swift 3 Step 2 var json = [String:Any]() json["key1"] = 1 json["key2"] = "2" // Swift 2 public typealias JSONDictionary = [String: AnyObject] // To Swift 3 Step 2 public typealias JSONDictionary = [String: Any] Alamofire 等三方库支持 iOS8
// 其实都是 !os(watchOS) 这个宏下面的 #if !os(watchOS) @discardableResult public func stream(withHostName hostName: String, port: Int) -> StreamRequest { return SessionManager.default.stream(withHostName: hostName, port: port) } @discardableResult public func stream(with netService: NetService) -> StreamRequest { return SessionManager.default.stream(with: netService) } #endif @escaping
let pedonmeter:CMPedometer = CMPedometer() func getPedometerDataFromDate(_ datet:Date?, withHandler handler: @escaping (CMPedometerData?, Error?) -> ()){ // 编译错误 pedonmeter.queryPedometerDataFromDate(startTime, toDate:endTime, withHandler: { (pedometerData:CMPedometerData?, error:NSError?) -> Void in guard let pedometerData = pedometerData else { return } handler(pedometerData, error) // 做一些事情 }) // 最后逼不得已只能不修改了,函数外面就做一些事情了 pedonmeter.queryPedometerData(from: startTime, to: endTime, withHandler: handler as! CMPedometerHandler) } Result of call to 'funtion' is unused
Date && NSDate
CAAnimationDelegate
@interface NSObject (CAAnimationDelegate)- (void)animationDidStart:(CAAnimation *)anim; - - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag;@end
@protocol CAAnimationDelegate @optional- (void)animationDidStart:(CAAnimation *)anim; - - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag;@end
其他
总结
更多工作之余,写了点笔记,如果需要可以在我的 GitHub 看 文章转自 Damonwong的简书
其他值得参考文献收藏:
|
请发表评论