Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6647651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:33:45+00:00 2026-05-26T00:33:45+00:00

Coming from a Flex-Flash IDE, I was able to set breakpoints in my code

  • 0

Coming from a Flex-Flash IDE, I was able to set breakpoints in my code and at runtime view the values of my variables in the corresponding window.

Now, I figured out where I can find the ‘variables’ window in Xcode and I can see all my variables there BUT the values of those variables can’t be seen. All I have is the data type and a bunch of hex numbers (pointers?).

How am I supposed to debug my code? Where can I see the values of my variables without having to log them in my code?

I am trying to see the values of a NSDictionary with a bunch of key/value pairs. But also any other NSObject for that matter. I have read something about overriding the description method but what about native objects?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:33:46+00:00Added an answer on May 26, 2026 at 12:33 am

    Debugging with GDB

    XCode gives you a GDB Debugger, so like Jano said in his comment, you can use GDB commands like po (print object) to view an object.

    po myObject
    po myDictionary
    po myArray
    

    To print primitives like int, float, you can use print, p, and px (to view the number in hex)

    print myInt
    p myInt
    px myInt
    

    You can also see the result of running commands. For example, to view a string length you could do:

    p (int) [myString length]
    

    If you do not cast the return to an int, I believe you’ll see some complaining in the console.

    To view a UIView’s frame (CGRect struct type), you can do:

    p (CGRect) [myView frame]
    

    Lastly, if you override the description method of a class, you can customize how it displays when written to the console or even to an NSLog for that matter. If you do [NSString stringWithFormat:@"My object... %@", myObj] the description method of that object will be called.

    - (NSString*) description
    {
       return @"This is the object description!";
    }
    

    Another good read is How to set a conditional breakpoint in Xcode based on an object string property?


    Log Tip

    If you want NSLog messages but only in debug builds, you might like the DLog macro we use at my work:

    #ifdef DEBUG
        #define DLog(...) NSLog(__VA_ARGS__)
    #else
        #define DLog(...) /* */
    #endif
    

    It works just like NSLog except that it is compiled out on non-DEBUG builds. NSLog can actually be a performance hit, plus you may not want some messages spilling out in your logs.

    We put this macro in the precompiled header file (MyApp-Prefix.pch) so that it gets included in all the project files.


    Dumping Variables

    Your comment asked about how to dump all variables of an object without writing code. I know of no built in way to do this. However, you might try using reflection. I have an implementation that will allow you to do something like:

    po [someObj dump]
    

    You can make a category on NSObject to add a method to all NSObject types that will dump the information you’re after. I borrowed code from Objective C Introspection/Reflection to start off the code, but added code to include property values.

    NSObject (DebuggingAid) category:

    #import <objc/runtime.h>
    @interface NSObject (DebuggingAid)
    
    - (NSString*)dump;
    
    @end
    
    @implementation NSObject (DebuggingAid)
    
    - (NSString*)dump
    {
        if ([self isKindOfClass:[NSNumber class]] ||
            [self isKindOfClass:[NSString class]] ||
            [self isKindOfClass:[NSValue class]])
        {
            return [NSString stringWithFormat:@"%@", self];
        }
    
        Class class = [self class];
        u_int count;
    
        Ivar* ivars = class_copyIvarList(class, &count);
        NSMutableDictionary* ivarDictionary = [NSMutableDictionary dictionaryWithCapacity:count];
        for (int i = 0; i < count ; i++)
        {
            const char* ivarName = ivar_getName(ivars[i]);
            NSString *ivarStr = [NSString stringWithCString:ivarName encoding:NSUTF8StringEncoding];
            id obj = [self valueForKey:ivarStr];
            if (obj == nil)
            {
                obj = [NSNull null];
            }
            [ivarDictionary setObject:obj forKey:ivarStr];
        }
        free(ivars);
    
        objc_property_t* properties = class_copyPropertyList(class, &count);
        NSMutableDictionary* propertyDictionary = [NSMutableDictionary dictionaryWithCapacity:count];
        for (int i = 0; i < count ; i++)
        {
            const char* propertyName = property_getName(properties[i]);
            NSString *propertyStr = [NSString  stringWithCString:propertyName encoding:NSUTF8StringEncoding];
            id obj = [self valueForKey:propertyStr];
            if (obj == nil)
            {
                obj = [NSNull null];
            }
            [propertyDictionary setObject:obj forKey:propertyStr];
        }
        free(properties);
    
        NSDictionary* classDump = [NSDictionary dictionaryWithObjectsAndKeys:
                                   ivarDictionary, @"ivars",
                                   propertyDictionary, @"properties",
                                   nil];
        NSString *dumpStr = [NSString stringWithFormat:@"%@", classDump];
    
        return dumpStr;
    }
    
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm coming from a flash/flex background, so forgive me if this is an off
I am coming from Flex where you can do just about anything inside of
Coming from a C# background the naming convention for variables and methods are usually
I'm a newbie doing Objective-C, coming from Flex/Actionscript development. I have an iPhone app
Coming from Robotlegs/PureMVC, I am pretty familiar with the concept of the view mediator,
coming from .Net world, just want to know what is the corresponding collection to
I am looking to get into Flash game development (coming from XNA), but I'm
Coming from a corporate IT environment, the standard was always creating a class library
Coming from a Classic ASP background, I'm used to multiple forms on a page,
Coming from a background, I'm familiar with GUI editors that do a poor job

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.