Turn FIXME, TODO, and !!! comments into compiler warnings

CATEGORIES :: iOS, Objective-C, Tutorial, Xcode

I have written a few posts on how to customize the jump bar function menu in Xcode. If you have not seen them click on the links below.

Learn more about #pragma marks

Learn more about FIXME, TODO, …

OK, great… Now you can see how customizing the jump bar function menu in xcode can make browsing your code within a single file easier. But, we are missing the ability to find these flags or notes from within the xcode IDE. I wanted to make the FIXME, TODO, ??? and !!! comments a little more useful. So, after some research I found a solution by Jake Marsh ( See references following this tutorial ). What he had done was expand off a code example that takes these comments as your application builds and turns them into compiler warnings. You can then see your comments and descriptions in the compiler warnings list. You can also jump to that comment just like a normal warning can from within xcode. Now, these are useful!

Lets take a look on how to add this functionality to your xcode project.

^Adding FIXME , TOD and !!! as compiler warnings

The first step is to go into your project navigator and select your project.

Read More

Adding TODOs, FIXMEs, and more to the jump bar in Xcode

CATEGORIES :: iOS, Objective-C, Tutorial, Xcode

Here are a few examples of how to customize the the jump bar functions menu within Xcode. Very similar to the way a #pragma mark will.

Not familiar with the #pragma mark directive? Click the link below to learn more about them.

Learn more about #pragma marks

OK, adding a FIXME, TODO, MARK, ??? or !!! comment to your code can be simple. Below are some examples showing you how.

!!

The examples below need to be outside of function brackets in order to show up in the jump bar function menu.

Read More

Adding custom warning messages in Xcode

CATEGORIES :: iOS, Objective-C, Tutorial, Xcode

Here a useful little tip for adding custom warning messages in Xcode.

Xcode, when compiling an application to run, will pick up the “#warning” flag and display it in the warnings list. This could be useful for many reasons but you can use them how ever you like.

Below is the correct syntax needed to add your own warning messages.

!!

Your message needs to be within quotes.

#Warning

#warning “Your custom warning message...”
Read More

You should be using Pragma Marks

CATEGORIES :: iOS, Objective-C, Tutorial, Xcode

Seriously you should…

This is not because I like clean, readable, code. This is because Pragma Marks are useful. These simple directives can provide helpful headers for sections of code but, the real benefit will come into play when you use the jump bar within Xcode. Each Pragma Mark you add will show up as a clickable link. So, yes you should use them because they provide better organization and…. easier navigation.

Here, to better explain, this is what a normal jump bar might look like.

As you can see, this is a plan flat list of jump items in your code. Now, the image below shows what your jump bar could look like when you add Pragma Marks.

A little better?? OK, now lets see how easy they are to use.

Read More

Device Information Macros

CATEGORIES :: iOS, Macros, Objective-C

Here are some useful Device Information Macros.

Macro

#import “UIDevice+Extended.h”

/** String: Identifier **/
#define DEVICE_IDENTIFIER ( ( IS_IPAD ) ? DEVICE_IPAD : ( IS_IPHONE ) ? DEVICE_IPHONE , DEVICE_SIMULATOR )

/** String: iPhone **/
#define DEVICE_IPHONE @"iPhone"

/** String: iPad **/
#define DEVICE_IPAD @"iPad"

/** String: Device Model **/
#define DEVICE_MODEL ( [[UIDevice currentDevice ] model ] )

/** String: Localized Device Model **/
#define DEVICE_MODEL_LOCALIZED ( [[UIDevice currentDevice ] localizedModel ] )

/** String: Device Name **/
#define DEVICE_NAME ( [[UIDevice currentDevice ] name ] )

/** Double: Device Orientation **/
#define DEVICE_ORIENTATION ( [[UIDevice currentDevice ] orientation ] )

/** String: Simulator **/
#define DEVICE_SIMULATOR @"Simulator"

/** String: Device Type **/
#define DEVICE_TYPE ( [[UIDevice currentDevice ] deviceType ] )

/** BOOL: Detect if device is an iPad **/
#define IS_IPAD ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad )

/** BOOL: Detect if device is an iPhone or iPod **/
#define IS_IPHONE ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone )

/** BOOL: IS_RETINA **/
#define IS_RETINA ( [[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2 )

/** BOOL: Detect if device is the Simulator **/
#define IS_SIMULATOR ( TARGET_IPHONE_SIMULATOR )
Read More

System Information Macros

CATEGORIES :: iOS, Macros, Objective-C

Here are some useful System Information Macros.

Macro

/** String: System Name **/
#define SYSTEM_NAME ( [[UIDevice currentDevice ] systemName ] )

/** String: System Version **/
#define SYSTEM_VERSION ( [[UIDevice currentDevice ] systemVersion ] )

Example

- (void)viewDidLoad
    {
        [super viewDidLoad];

	    NSString * sysName = SYSTEM_NAME;
	    NSString * sysVersion = SYSTEM_VERSION;
    }
Read More
Page 1 of 612345...Last »