In Xcode, the values of variables cannot be directly viewed in Debug mode like those in eclipse or VS integrated development. So how can I view XCode variables during debugging?
There are some methods.
1. Create a Single View App
Add some code in viewDidLoad:
- (void)viewDidLoad{ [super viewDidLoad]; NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@"value1",@"key1", @"28", @"age",@"rongfzh",@"name" ,nil]; UILabel *label = [[UILabel alloc] init]; label.frame = CGRectMake(20, 40, 250, 60); label.text = [dic objectForKey:@"name"]; [self.view addSubview:label];}
Place a breakpoint on the last line.
2. "po": print object command to print the object.
Command + R Debug run, input on lldb on the Debug ConsolePo dicPress enter, as shown below:
This prints out the dictionary content.
Print the label again.
(Lldb)Po label
(UILabel *) $3 = 0x06a8bdd0 <UILabel: 0x6a8bdd0; frame = (20 40; 250 60); text = 'rongfzh '; clipsToBounds = YES; userInteractionEnabled = NO; layer = <CALayer: 0x6a8be90>
The label information is also printed.
3. print command
Print (char *) [[dic description] cString]
(Char *) $4 = 0x06d79760 "{\ n age = 28; \ n key1 = value1; \ n name = rongfzh; \ n }"
Print the retainCount of the object, but the object is recycled.
(Lldb) print (int) [label retainCount]
(Int) $2 = 1