1. OC 单例
+ (NetworkTool *)sharedNetworkTool { static id instace; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ instace = [[self alloc] init]; }); return instace; }
2. Swift 单例
private static let instance = NetworkTool() class func sharedNetwork() -> NetworkTool{ return instance }
时间: 2024-10-06 23:23:33