Thursday, April 14, 2011

Objective C - making long lines of code readable

I was writing text for a UILabel object;  it was long and spanned multiple lines.  I could have just made it one long string in code but this would be unreadable.  I  found that the backslash character is the continuation character that lets you write on separate lines in code.  
So for example:
UILabel* lblLongtext = @"This text is so long I need to "\
                                    "continue it on another line.";


"Write code like you know the person who will be maintaining your code knows where you live and has a gun."

No comments:

Post a Comment