Skip to main content

Posts

Showing posts with the label iPhone

Removing NSLogs from release build

NSLogs are great when debugging to see exactly what is going on but the downside is that they impact heavily on performance (I speak from experience on that one). Luckily there is a way to "disable" them on release builds of your application and still have them in your debug builds. we do this by simply adding the following macro to the prefix .pch file in your project or anywhere before the entry point to your application. #ifdef DEBUG #define NSLog(...) NSLog(__VA_ARGS__) #else #define NSLog(...) {} #endif If you want an explanation here it is. When you build a Debug version of an application DEBUG is defined , if its a release build , DEBUG is not defined.This macro checks if DEBUG is defined , if it is it sets NSLog to what it should be , if DEBUG is not defined then NSLog is defined as an empty code block that as you should know will do nothing , thus saving on performance.

Color status bar on iPhone

This is just a quick tip with some basic logic on how to get a colored status bar on an iphone app ,here i will be assuming that the app does not rotate so i will be placing all the code in appdelegate in the - ( BOOL )application:( UIApplication  *)application didFinishLaunchingWithOptions:( NSDictionary  *)launchOptions So the secret is really that there is no secret ,apples framework does not allow you to choose the color of the status bar so instead we set the status bar to the translucent  predefined style of  UIStatusBarStyleBlackTranslucent  and then we draw a colored view behind it to make it appear as though the color of the bar has changed. Here is a sample where i "tinted" the statusbar cyan in the app delegate : - ( BOOL )application:( UIApplication  *)application didFinishLaunchingWithOptions:( NSDictionary  *)launchOptions {         [[ UIApplication   ...