Interesting Discoveries while debugging

Next time you’re in the console debugger, have some fun with the following:


Assume you have an object with variable name myObject

p *page   // gives you a nice summary of the members of this object
p &*page   // gives you the address of the object.  
           //Useful if you want to write your own description method without calling super
- (NSString*)description
    return [NSString stringWithFormat:@"<%@: %p>",
            &*self];  // for the noob:  & give me the memory address to the (*) pointer of the object responding to self

Useful if you are using CoreData objects but you don’t like the way they clutter up your console.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s