David Seek David Seek - 1 month ago 9
Swift Question

What is the print result of an object?

Printing the

tableView
object:

override func viewDidAppear(_ animated: Bool) {
print(tableView)
}


Results in
<UITableView: 0x7fe33701e000...


Is
0x7fe33701e000
the memory address of the object
tableView
or is it the ID or what is it? Help is very appreciated.

Addition

override func viewDidAppear(_ animated: Bool) {
withUnsafePointer(to: &tableView) {
print("\(tableView) has address: \($0)")
}
}


Results in:

<UITableView: 0x7fcdca810600... has address: 0x00007fff594533f0


So I'm able to exclude the idea that it might be the memory address(?).

Answer

0x7fcdca810600 is the address of the UITableView instance pointed to by the tableView variable.

0x00007fff594533f0 is the address of the tableView variable.

Your original thought was correct.

BTW - the output of printing classes, such as UITableView is from the description method. The default is to show the object's type and memory address. You can change the output by implementing or overriding the description method.