Duck
Duck

Reputation: 35973

NSLog the address of NSArray

When I type this on console

print myArray       .... myArray is a NSArray

I see this

(NSArray *) $0 = 0x00006100002494e0 @"6 objects"

How do I build a NSLog line to print this address 0x00006100002494e0 to console?

Upvotes: 0

Views: 302

Answers (2)

Jason Coco
Jason Coco

Reputation: 78373

Use the %p format specifier, which prints an address or pointer variable:

NSLog(@"Address of my array: %p", myArray);

Upvotes: 2

Quxflux
Quxflux

Reputation: 3303

NSLog(@"%p", myArray);

Would be suitable.

You can see a list of format specifiers in the Apple documentation over here.

Upvotes: 3

Related Questions