什么是Objective-C调试提示? [英] What are some Objective-c debugging tips?

查看:102
本文介绍了什么是Objective-C调试提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我仍然没有正确学习如何使用Xcode调试器,但我想知道是否有人有一些最喜欢的调试提示,你可以快速插入代码来查看对象的状态。任何有助于我更好地掌握Objective-c内部的东西。



我主要依靠 NSLog(@%@ ,myObject),以查看myObject发生了什么,或者有时候 NSLog(@%@,[myObject class])真的应该是班级。我知道我可以通过使用调试器来做到这一点,但是我想在使用完整的调试器之前先尝试使用代码。



你有类似的技巧吗?

解决方案

Asserts。很多很多的断言。当你认为某事必须是某种方式时,断言这是真的。



Build&分析是新的Build。在雪豹中使用Clang Static Analyzer。



没有魔法;您的系统和代码中的所有内容都出于某种原因,包括崩溃和不正当行为。



拥抱调试器;这是真的很强大,很容易开始使用。



Greg Parker的博客是一个很好的来源,为一幕幕的看法了解一些事情如何: http://www.sealiesoftware.com/blog/


I'm still haven't properly learned how to use the Xcode debugger, but I was wondering if anyone has some favourite debugging tips, things you can quickly insert into code to see the state of objects. Anything which would help me get more of a grasp on the internals of Objective-c.

Mostly I rely on NSLog(@"%@", myObject) to see what's happening with myObject, or sometimes NSLog(@"%@", [myObject class]) to check that something is really the class it should be. I know that I can do both by using the debugger, but I want to try using code for the moment, before I take the leap into using a full debugger.

Do you have any similar tricks?

解决方案

Asserts. Lots and lots of asserts. When you assume something must be some way, assert that it is true.

Build & Analyze is the new Build. Use the Clang Static Analyzer in Snow Leopard.

There is no magic; everything on your system and in your code happens for a reason, including crashes & misbehavior.

Embrace the debugger; it is really powerful and quite easy to start using.

Greg Parker's weblog is a wonderful source for a "behind the curtains" view of how some things work: http://www.sealiesoftware.com/blog/

这篇关于什么是Objective-C调试提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆