Archive for the ‘nslog’ tag
Custom NSLog for Xcode 4
This post describes how you can to setup a custom NSLog snippet in Xcode 4. By default, this custom NSLog prints the class and method name of the position it is inserted.
Please follow these steps to add the code snippet to the scripts in Xcode 4.
- Copy and paste the following code into your editor. Anywhere.
NSLog(@"%@ %@", self.className, NSStringFromSelector(_cmd)); /* DEBUG LOG */
- Open up the code snippets library which sits in the utility pane on the right side. Look for the curly braces {}.
- Highlight the above mentioned code – click and hold the mouse over the text (for a short while) – drag them into the code snippet library.
- Afterwards you can edit the snippet and add a title, summary and a completion shortcut. I used the following settings:
Title: Custom NSLog (Class & method name) Summary: NSLog prints the class and method name Platform: All Language: Objective-C Completion Shortcut: NSLog Completion Scopes: All
You are welcome to comment and post your custom code snippets!
This article is inspired by the post “Easy Doxygen code snippets for Xcode 4” by Chris Powell.