How to Debug Xcode in iOS

Source: Internet
Author: User
Tags print object

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

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.