IOS-----Xcode-debug Try

Source: Internet
Author: User
Tags print object

In Xcode, when you debug, you can't see the value of a variable directly, like Eclipse, or vs those integrated development. So how do you look at Xcode's variables while debugging?

There are some ways.

1. Create a new single View App

Add some code to the Viewdidload:

-(void) viewdidload{    [Super Viewdidload];        Nsdictionary *dic = [nsdictionary dictionarywithobjectsandkeys:@ "value1", @ "Key1",                         @ "+", @ "age", @ "Rongfzh", @ " Name ", nil];        UILabel *label = [[UILabel alloc] init];    Label.frame = CGRectMake (+, +, +);    Label.text = [dic objectforkey:@ "name"];    [Self.view Addsubview:label];}

Make a breakpoint on the last line.

2. "Po": Print object is printed out by the Print Object command.

Command+r Debug Run, on the debug Console on the LLDB input po dic Enter, shown as follows:

This will print out the contents of the dictionary.

Try printing the label again.

(LLDB) PO Label

(UILabel *) $ $ = 0x06a8bdd0 <UILabel:0x6a8bdd0; frame = (20 40; 250 60); Text = ' Rongfzh '; Clipstobounds = YES; userinteractionenabled = NO; Layer = <CALayer:0x6a8be90>>

The label's information is also printed out.

3. Print command

Print (char*) [[dic description] cString]

(char *) $4 = 0x06d79760 "{\ n age = 28;\n Key1 = value1;\n name = rongfzh;\n}"

Prints the object's Retaincount, but the object is recycled

(LLDB) print (int) [Label Retaincount]

(int) $ = 1

IOS-----Xcode-debug Try

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.