Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Tutorials > Tutorial Discussion

Reply
 
LinkBack Thread Tools Display Modes
Old 12-31-2010, 07:24 PM   #1 (permalink)
Indie Developer
 
iSDK's Avatar
 
Join Date: Jul 2010
Posts: 1,346
iSDK is on a distinguished road
Send a message via AIM to iSDK
Default Tutorial: Customising the NSLog Function.

Hey, here is a quick code snippet on how to customise your own NSLog.

Your Own Named NSLog:

Code:
#define iSDKLog(s, ...) NSLog(@"%@", [NSString stringWithFormat:(s)])
You can use it by doing this:

Code:
iSDKLog(@"Hello World");
If you use this function, it returns this in console:

Code:
Hello World
Your Own Named NSLog showing the method you NSLog'ed :

Code:
#define iSDKMethodLog(fmt, ...) NSLog((@"%s" fmt), __PRETTY_FUNCTION__);
That returns this in console:
Code:
-[Music_ChartsAppDelegate application:didFinishLaunchingWithOptions:]hello world
Your own named NSLog showing the line name:

Code:
#define iSDKLineLog(fmt, ...) NSLog((@" [Line %d] " fmt),__LINE__, ##__VA_ARGS__);
That returns this in console:

Code:
[Line 27] hello world
and finally: Your own named NSLog showing the line and method name:

Code:
#define iSDKMethodAndLineLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
That returns this in console:

Code:
-[Music_ChartsAppDelegate application:didFinishLaunchingWithOptions:] [Line 26] hello world
Hope this helps you debug your projects!!
iSDK is offline   Reply With Quote
Old 01-01-2011, 12:32 PM   #2 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

cool, nice share.
__________________
dany_dev is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Stats
Members: 175,696
Threads: 94,139
Posts: 402,961
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jasper_muc
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:56 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0