开发者

How to see multi-byte strings in Xcode

Is it possible to see strings that use 16 bits chars in Xcode debugger? I use a开发者_如何转开发 custom string class, not NSString. The strings are NULL terminated. The only way I can see the strings is if I see them as memory, but they are hard to read.

Thank you!


You'll need to write a data formatter bundle -- just writing the data formatter expressions inside the debugger isn't enough. Viewing strings in the Xcode debugger is a black art. Even once you've written the data formatter bundle, be prepared for them not to work at least 50% of the time. We've been fighting this issue for about 5 years now. Most of the time the debugger will tell you the variable is no longer in scope when it really is, and you'll still need to drill down into the members to view the raw memory anyway.

Something that may make it easier (I haven't tried this) is to write a method in the class that returns an NSString and then you may be able to get the data formatter expressions to display something useful.


Use Data Formatting in the XCode debugger


For custom classes I always found it helpful to implement description and debugDescription methods. Maybe this approach will be sufficient in your case too.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜