Avatar ·

How to print the memory address of a variable in Swift? (for debugging)

Hi everyone! I'm a beginner iOS developer and I've encountered a problem while debugging code. I need to understand whether two variables refer to the same object in memory or if they are different copies. I know that in Objective-C you could simply use `%p` in `NSLog`, but in Swift with its strict typing it's more complicated. I've tried different approaches, but so far without success. Here's an example I'm interested in: ```swift class Person { var name: String init(name: String) { self.name = name } } let person1 = Person(name: "Alice") let person2 = person1 person2.name = "Bob" print(person1.name) // Prints "Bob" — so it's a reference type ``` How can I print the actual memory address where the `person1` and `person2` objects are stored, to confirm that they are indeed the same object?