swift泛型取值和字符保留几位小数

     ImageCache.default.calculateDiskStorageSize { (results) in
                    print("硬盘大小 is \(results)")
                  let string =  results.map({ String($0) })
                    results.map { num1 in
                        print(num1)
                    }
                    print(string)
            
                    do {
                        let value = try string.get()
                        
                        let num =   (Double(value) ?? 0.0) / 1000.0 / 1000.0
                        
                        self.contentLabel.text = String(format: "%.1fM", num)
                        print(value)
                        
                      
                    }catch{
                        print("\(error)")
                    }
//                    let integerResult = getNextInteger()
//                    integerResult == .success(5)
//                    let stringResult = integerResult.map({ String($0) })
//                    stringResult == .success("5")
                    
//                    let integerResult: Result = .success(5)
                  ///     do {
                  ///         let value = try integerResult.get()
                  ///         print("The value is \(value).")
                  ///     } catch {
                  ///         print("Error retrieving the value: \(error)")
                  ///     }
                  ///     // Prints "The value is 5."
                }

你可能感兴趣的:(swift泛型取值和字符保留几位小数)