代码之家  ›  专栏  ›  技术社区  ›  sadmicrowave

如何在Xcode和Objective-C中正确调试

  •  0
  • sadmicrowave  · 技术社区  · 14 年前

    我想知道在用Objective-C编码时,是否有一种有效的方法来调试Xcode中的问题。我经常创建网页,用jquery和javascript编写代码,您可以在代码的不同位置设置各种警报框,以确定脚本是否正确地执行了部分。您能在Xcode中做类似的事情来确保您的脚本正确地执行方法和创建变量吗?

    谢谢

    3 回复  |  直到 14 年前
        1
  •  2
  •   davbryn    14 年前

    NSLog

    NSLog(@"this text appears");
    

    CGFloat pi = 3.14;
    NSString *aFloatString = [NSString stringWithFormat:@"%.2f", pi];
    NSLog(@"pi is equal to: %@", aFloatString);
    

    %d %.2f %@ NSString*

    #IFDEF

    OUTPUT:
    Number of vertices is: 1200
    <Requested reduction>
    Can I kick it?
    ....
    ....
    YES. I. CAN!
    Number of vertices is: 800
    

        2
  •  0
  •   KevinDTimm    14 年前

        3
  •  0
  •   NeilMonday    14 年前

    NSLog(@"Some status message here");
    NSLog(@"The value of myObject is:%@", myObject);