Category Archives: iPhone

Xcode Color Themes


This is a small collection of my personal preference of color themes for xcode programming environment. For those who are looking for a dark theme. You can chose from one of the following color themes. I’m currently using teliaz theme, it has been tested and works very smoothly.

To get

teliaz theme

run the following code in Terminal:

mkdir -p ~/Library/Application\ Support/Xcode/Color\ Themes; cd ~/Library/Application\ Support/Xcode/Color\ Themes; curl http://teliaz.com/files/apple/TeliazTheme.xccolortheme &> TeliazTheme.xccolortheme

To get

Ego theme

run the following code in Terminal:

mkdir -p ~/Library/Application\ Support/Xcode/Color\ Themes; cd ~/Library/Application\ Support/Xcode/Color\ Themes; curl http://teliaz.com/files/apple/XCodeColorTheme.xccolortheme &> EgoTheme.xccolortheme

“EGO” uses the font “DejaVu Sans Mono” at 12pt. Some of you may know it as “Panic Sans” from Panic’s Coda (which is a repackaged version of it). You can grab the font over at dejavu-fonts.org. If you already have Code installed, feel free to swap in Panic Sans in place of DejaVu Sans Mono.

To get

Humane Theme

run the following code in Terminal:

mkdir -p ~/Library/Application\ Support/Xcode/Color\ Themes; cd ~/Library/Application\ Support/Xcode/Color\ Themes; curl http://teliaz.com/files/apple/Humane.xccolortheme &> Humane.xccolortheme

Now just restart Xcode, go to Preferences > Fonts & Colors, and select “one of these themes” from the color theme drop down. Hope you like it!! Happy coding…

Objective C – Basic Datatypes and NSLog


Have you been frustrated sometimes trying to debug an application and really making it worse, the output of your logs are not as desired. Complete chaos and nonsense.

Some of the concepts here will be familiar in c coding language, as objective c is just an extended c with object oriented approach. Take a quick look at this table that will surely clear things up.

Type Constants NSLog Short Explanation
char "a", "\n" %c
short int %hi, %hx, %ho %hi, %hx, %ho
unsigned short int %hi, %hx, %ho %hi,
%hx (hex notation),
%ho (octa notation)
int 12, -97, 0xFFE0, 0177 %i, %x, %o also %d can be used in objective-c
unsigned int 12u, 100U, 0xFFU %u, %x, %o as above
long int 12L, -200l, 0xfffL %lu, %lx, %lo as above
long long int 0xe5e5e5e5LL, 500LL %lli, %llx, %llo as above
long long unsigned int 0xe5e5e5e5ULL, 120ULL %llu, %llx, %llo as above
float 12.34f, 3.1e-5f %f, %e, %g %f (with 6 decimal place by default),
%e (with scientific notation), %g (personal preference most readable)
double 12.34, 3.1e-5 %f, %e, %g as above
long double 12.34l, 3.1e-5l %Lf, %Le, %Lg as above
id %p

NIBs or code? Why not both? Here’s nib2objc.


(Somehow this project seems to me so simple, that I’m sure someone has done this before. Anyway). This is my feeble attempt to bring an answer to the eternal dichotomy between those arguing about the relative benefits of creating user interfaces via Interface Builder or via pure Objective-C code: let me introduce nib2objc.
Continue reading NIBs or code? Why not both? Here’s nib2objc.

Objective-C Categories as Stylesheets


It is very important that iPhone and iPad applications use visual styles in a coherent way. This helps users learn how to use your application faster, it helps them scan your UI for important information as quickly as possible, and it also can convey a strong marketing message; companies who want iPhone or iPad applications often have complex visual identities, including predefined fonts and colors, and they will want their applications to match those choices.
Continue reading Objective-C Categories as Stylesheets

Trace freed/deallocated instances of objects

This procedure has saved me more than once, so I need to document it throughly for everyone! There are cases where I see messages (in the debugger console) that are like this;

 >-[NSFetchedResultsController class]: message sent to deallocated instance 0x11957d0

Sometimes, it will talk about “freed” instead of deallocated. That address at the end is important. To track down the line of code where the object was allocated, you’ll need to set a couple environment settings. To do this, right click on the executable you’re trying to debug and select “get info”. Select the “arguments” tag and set the values shown below;

MallocStackLoggingNoCompact 1

NSZombieEnabled YES

debug environment settings

(be sure to disable these when you’re done. They should not be enabled for a production build!)

Next, run your program and test enough to generate the error. In the Debugger Console, copy that hex address value, then type the command;

(gdb) info malloc-history <paste-address-here>

You should see something like this;
Stack – pthread: 0xa0416720 number of frames: 28
0: 0x9264382d in malloc_zone_calloc
1: 0×92643782 in calloc
2: 0×93611618 in _internal_class_createInstanceFromZone
3: 0x9361ab08 in _internal_class_createInstance
4: 0x3020275c in +[NSObject allocWithZone:]
5: 0x3020264a in +[NSObject alloc]
6: 0x3d92 in -[AMRAPViewController fetchedResultsController] at /Users/dkavanagh/CrossFit Timer/Classes/AMRAPViewController.m:146
7: 0x3a18 in -[AMRAPViewController viewWillAppear:] at /Users/dkavanagh/CrossFit Timer/Classes/AMRAPViewController.m:96
8: 0x3097c945 in -[UINavigationController _startTransition:fromViewController:toViewController:]
9: 0x30977c33 in -[UINavigationController _startDeferredTransitionIfNeeded]
10: 0x3097d01e in -[UINavigationController pushViewController:transition:forceImmediate:]

The first line below the object alloc (in my case, line 6) will show where the offending object was allocated and should really help in tracking down the free/dealloc problem.