Archive for February, 2009

Parsing serialized .NET DateTime to NSDate

Wednesday, February 25th, 2009

In my application I have to parse a serialized .NET DateTime returned from a REST service to a NSDate object. I expected to be able to use the initWithString: constructor of the NSDate class, but this wasn’t the case. The initWithString: constructor expects a string with the following format “2009-02-25 22:00:00 +0100″, yet the serialized .NET DateTime is in the following format “2009-02-25T22:00:00+01:00″. Notice the “T” and the semicolon in the timezone offset.

To solve this difference in format, one could manipulate the actual string to comply to the desired format or one could use the NSDateFormatter class. The latter being the “cleanest” solution.

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];
NSDate *date = [formatter dateFromString:text];

The used format patterns comply to the Unicode standard UTS #35.

Breakpoints in Xcode stop firing

Wednesday, February 25th, 2009

Apple’s Xcode is a nice IDE and just like every program it has its occasional quirks. Here’s a tip: when all of a sudden your breakpoints stop firing, without any apparent reason, try this: Instead of following Googles advice and deselecting the “Load symbols lazily” option in the Preferences screen, (which will solve the breakpoints not hitting, I have to admit) perform a cleanup of your target. (Build – Clean All Targets) This will remove all intermediate files created during the build process and will force Xcode to process every file the next time you build, basicly a full rebuild. Xcode processes only the changed files during subsequent builds, but apparently this incremental strategy fails once in a while, with the aforementioned effect.

In the end both methods solve the problem, but I like to leave the default settings on, instead of changing them to fix some glitch in the system.

As posted on Smartasses.

Blog up and running

Wednesday, February 25th, 2009

Well, finally installed a blog. I’ll be posting some Emmer Inc related news and general Cocoa/Xcode articles here, if all goes to plan. I chose for Wordpress since I’d rather spend more time actually coding for the iPhone than writing my own blog engine. So forgive me for using a default theme instead of integrating the blog into the main Emmer Inc website. Which still has to be made too.

The current schedule is to release our (or my) first iPhone application somewhere in March. The main building blocks have been written and I’m in the progress of cleaning things up and improving the overall responsiveness. Still debating what’s more important for version 1.0 though, features or eye candy? Expect an article introducing the first application on this blog soon.

See you all in the App Store!