In a breakpoint action, I'm going this:
@(const char *)[(NSString*)[myobject retainCount]UTF8String]@
which gives this output:
<Error: Cannot access memory at address 0x2>
If I do this:
@(NSString*)[myboject retainCount]@
it outputs a memory address. But if I do this in code:
NSLog(@"retain count is: %d", [myobject retainCount]);
it gives this output:
2009-04-18 09:58:48.085 myapp[80277:20b] retain count is: 1
What is the syntax needed to output correctly in the breakpoint action?
Also, where can I find a complete listing of the format keys for breakpoint actions?
-
You should be able to actually use a "Debugger Command" breakpoint action over the "Log" action, setting the command text to:
p (int)[myObject retainCount]
If you want to log the description of an Objective-C object:
po myObject
You can use a Log action before it to display a message indicating what is being printed if you want.
As for the specific retain count issue you're logging in this case, examining retain counts directly and trying to solve memory related bugs that way isn't considered a great practice. See this post for a good explanation about that.
-
retainCount returns a number. Simply casting it to a string is incorrect, since it's a number, not a string. To print a number as a string you have to either call:
printf("%d",[myobject retaincount]);
or print out this string:
[NSString stringWithFormat:@"%d",[myobject retaincount]];
0 comments:
Post a Comment