For example, if I want to know the return of
[NSKeyedArchiver archiveRootObject:self.privateItems toFile:[self.itemArchPath absoluteString]];
What could I do ?
In lldb and in Xcode, if you "step-out" of some function, when the step-out completes, we'll show the return value of the function you just left.
In Xcode, on stop after step out, the first element of the Locals view (called "Return Value") will be the return value of the function you just stepped out of.
If you are in command-line lldb the same thing will show up in the thread part of the stop printing:
(lldb) fin
Process 43838 stopped
* thread #1: tid = 0x849c80, 0x0000000100000f5b SimpleStepOut`main(argc=1, argv=0x00007fff5fbff5b8) + 27 at main.c:18, queue = 'com.apple.main-thread', stop reason = step out
Return value: (int) $0 = 5
frame #0: 0x0000000100000f5b SimpleStepOut`main(argc=1, argv=0x00007fff5fbff5b8) + 27 at main.c:18
15
16 int main(int argc, const char * argv[]) {
17 // insert code here...
-> 18 printf("Hello, World - %d!\n", return_five());
19 return 0;
20 }
Note, if you've customized your frame-format, you may not have this element, it's thread.return-value.
It's a little harder to do this when a "step in/out" happens to step out of the function, so for now it only works if you leave the function by stepping out.
If you want to see the result of [NSKeyedArchiver archiveRootObject:self.privateItems toFile:[self.itemArchPath absoluteString]] you could just wrap its result in a simple conditional statement and print a message: that method returns a boolean, so it's either true or false.
Example:
bool result = [NSKeyedArchiver archiveRootObject:self.privateItems toFile:[self.itemArchPath absoluteString]];
if (result) {
NSLog(@"It worked!");
} else {
NSLog(@"It failed!");
}
If you mean you want to check what was saved, then you should probably either print the path you saved to and look at it in on your Mac (if you're using the simulator) or try re-loading the object to make sure it matches what you expected.
p @eax could work.bool result line then inspect the contents using p result, but make sure the scope doesn't end (i.e., put int meh = 10 or something after just to be sure) otherwise Xcode might lose track of the value. There aren't many advanced ways to view a boolean :)TwoStraws answer is correct.
If, however, you are looking to find the return value (result in TwoStraws's answer) while debugging and only while debugging, you can step into the call to archiveRootObject:toFile: and then hit F8. That'll step out of the function and (usually) include a pseudo-local variable named "return" that will hold the return value from the call.
po [NSKeyedArchiver archiveRootObject:self.privateItems toFile:[self.itemArchPath absoluteString]]should return the bool result of the save but that would save again. If you wanted to see the result after the save (above your breakpoint), I think you'd need to capture the result somehow as:BOOL saveResult = [NSKeyedArchiver archiveRootObject:self.privateItems toFile:[self.itemArchPath absoluteString]]