Our DNA is written in Objective-C

Category Archive for ‘Q&A’ rss

Beware of NSString Optimizations

There are some scenarios where NSString acts as a class cluster internally to optimize handling of certain strings. One such case bit me today, and so I want to tell you about it.

Class clusters work such that you think you are always dealing with just instances of NSString, but in reality the runtime goes and chooses different subclasses for certain tasks. You might have already seen some effects of this behavior when debugging and the debugger actually showing you something other than NSString as the type of a variable.

Read more

BSA Banner

ObjectiveSee Interview

ObjectiveSee is a web site dedicated to interviewing iOS developers. They use the format of a Q&A and they have several intriguing people’s up already: Justin Williams, Nathan Spindel, Keith Blount, Whitney Young, … oh and ME!

iOS 5 Breaking NSDateFormatter?

Robert Meraner asks:

“Do you have any idea why this code works in iOS 4.3, but no longer under iOS 5? Googling it seems to turn up some ideas, but no immediate explanation.”

This is the code Robert refers to:

NSString *currentElementValue = @"01.12.2011 09:35:13 CET";
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"dd.MM.yyyy HH:mm:ss zzz"];
NSDate *date = [dateFormatter dateFromString:currentElementValue];

This got me confounded initially as well, but thanks to Cédric Luthi we got an official answer to this riddle: works as intended!

Read more

Bit Masks


Joseph Collins asks:

How do you decipher a bit mask from an argument which logically OR’d multiple values together? Enum uses bit shifting.

This question came to me while looking at UIView’s header file and wondering how Apple handles the animation options bitmask.

If you have several modes of something then usually you get by with an emum. But if you can combine several flags in s single value then you have to do this by means of bit masks. Let’s explore these today.

Read more

Coding Style

Dany asked:

I’m looking at your (nice) project NSAttributedString-Additions-for-HTML and I have some questions about your convention of writing code.
I really hope that you can reply to me, and maybe can be an idea for a future blog post (on naming conventions, and conventions in general for objective-c).

I adopted several styles I read about in the coding style guides by Google and Marcus Zarra, though I have to admit I only skimmed through these and picket a couple of things that made sense.

Though it is good practice to reflect on your style every once in a while to see if it still serves the purpose of making your code easier to maintain and read.

Read more

Podcasts for iOS Developers

I once dabbled a bit in podcasting myself with the Dr. Touch / Cocoanetics podcast, but I decided that I am not going to continue that on my own. I still like to TALK about it, if there’s somebody out there looking for a co-host …

Update: I resurrected the Cocoanetics Podcast! Subscribe to it on iTunes or add the RSS feed to your favorite podcasting app or listen to the shows right on this website.

Whenever I walk the dog, doing chores or “grounding myself” while gardening I like to listen when experts in our industry are discussing latest developments that impact my professional live as iOS developer.

So I asked on Twitter what your favorite related shows are and from the answers I made this list. And YES I checked it twice (several people were asking).

Read more

NSAttributedString+HTML Q&A

Over the past few months I have received questions about NSAttributedString+HTML and Rich Text Editing. Here are the Frequently Asked Questions.

I generally abbreviate NSAttributedString+HTML as NSAS+HTML. If your question or app is not in this list please let me know.

Read more

Adding Fading Gradients to UITableView

Masked Table View

Jason Jardim asked (4 Months ago):

This is just a screen shot I found with someone posting a similar question.  I am trying to fade out he top/ bottom cells in a tableview. How do I achieve this effect?

First of all, Jason, I am sorry it took so long. I was extremely busy during the past few months but I kept your e-mail at the bottom of my inbox as something that I am really interested in to give a good answer to.

Let me make it up for you by proposing several solutions to your question as well as show one that I find the coolest.

Read more

Is it safe to install iOS 5 on your everyday iPhone?

On the heels of the iOS 5 announcement I started getting a multitude of e-mails asking more or less the same thing:

I have only my everyday iPhone for developing, so usually I am careful with updating. Do you think that iOS 5 is sufficiently developed and error free to install it on your main phone?

Sorry, but actually my first reaction to this question is to laugh out loud. But – once I have regained my composure – let me give you a serious answer to this question which is probably really not meant as a joke.

Read more

Prepaid 3G Data for Visitors to the USA – Truth and Fiction

As a fellow iOS Developer you might find yourself in San Francisco for WWDC or maybe on assignment. If you’re like me then you cannot survive with a modicum of connectivity. Unfortunately AT&T has visitors jump through hoops and has loads of horror stories in stock to deter people from getting what they really want.

Thanks to my sponsors at Scribd I’m here in San Francisco for the second time this year and I would like to summarize what I have learned about your options when it comes to getting affordable wireless data for the short time you’ll be in the USA.

So far I have found two viable options, the easier one being with T-Mobile, the harder but ultimately more enjoyable one going via the main iPhone carrier in the US, AT&T.  Read more