I am getting an error "Cannot invoke initializer for type 'String' with an argument list of type '(Int64?)'" with nil-coalescing operator.
There are similar questions on stackoverflow, but they did not give me the solution I need.
My code with errors in comments:
let cell = tableView.dequeueReusableCell(withIdentifier: "countCell", for: indexPath)
cell.textLabel?.text = String(detailItem?.count) ?? "1" // Cannot invoke initializer for type 'String' with an argument list of type '(Int64?)'
let cell = tableView.dequeueReusableCell(withIdentifier: "countCell", for: indexPath)
cell.textLabel?.text = String(Int(detailItem?.count)) ?? "1" // Cannot invoke initializer for type 'Int' with an argument list of type '(Int64?)'
let cell = tableView.dequeueReusableCell(withIdentifier: "countCell", for: indexPath)
cell.textLabel?.text = String(Int(detailItem!.count)) ?? "1" // Cannot invoke initializer for type 'Int' with an argument list of type '(Int64?)'
let cell = tableView.dequeueReusableCell(withIdentifier: "countCell", for: indexPath)
cell.textLabel?.text = String(detailItem?.count ?? "1") // Cannot convert value of type 'String' to expected argument type 'Int64'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
171 次 |
| 最近记录: |