2012 Red Ribbon Ride Contest Winner!
Posted: April 15th, 2012 | Author: Michael | Filed under: Cycling | No Comments »If you haven’t donated yet, there is still time. Please visit this link to make a donation.
If you haven’t donated yet, there is still time. Please visit this link to make a donation.
This week I wanted to store a complex data type using NSUserDefaults. Unfortunately, NSUserDefaults only allows you to store common types. Storing objects using NSUserDefaults can be accomplished by using NSData and NSKeyedArchiver.
The code below uses NSKeyedArchiver to archive someObject then store the NSData object in the defaults.
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSData *data = [NSKeyedArchiver archivedDataWithRootObject:someObject]; [defaults setObject:data forKey:@"someKey"]; [defaults synchronize];
To retrieve the object from the user settings, retrieve the NSData object using the same key that was used to store the object. Then use NSKeyedUnarchiver to retrieve the object.
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSData *data = [defaults objectForKey:@"someKey"]; SomeObject *someObject = [NSKeyedUnarchiver unarchiveObjectWithData:data];
The class of the object that is being archived/unarchived must implement these two methods. If the object has a property that is not a common type, then that object must also implement these methods.
-(void)encodeWithCoder:(NSCoder *)encoder
{
[encoder encodeObject:self.itemId forKey:@"itemId"];
[encoder encodeObject:self.title forKey:@"title"];
}
-(id)initWithCoder:(NSCoder *)decoder
{
self.itemId = [decoder decodeObjectForKey:@"itemId"];
self.title = [decoder decodeObjectForKey:@"title"];
return self;
}
I have been doing iOS development for a few months now and I have come across some nice frameworks to assist in documentation, exception logging, and even a framework to help manage beta testing. I have found the following three frameworks invaluable in my current project:
Do you have any frameworks you use in your projects (iOS or Android) that you find beneficial? Leave a comment if you feel like sharing one or many!
How Facebook Mobile Was Designed to Write Once, Run Everywhere.
I recently read the above article on ReadWriteWeb.com. The article describes the technical architecture of the Facebook mobile applications and the direction they are heading. The article is based on a presentation that a Facebook engineering manager gave. He seems proud of the architecture and the so-called progress of the application. In reality, the Facebook application gets worse every day and has gone from being one of the best apps to one of the worst. It isn’t coincidental that as Facebook has moved from a native app to a more web-based app wrapped as a native app that the user experience has diminished. The app use to feel native, was virtually bug free, responsive, and accurate. Now, the app barely works. Bugs are littered throughout the application from pictures being un-viewable to some friends having profile pictures that are of a different Facebook friend. It’s classic that this article has “Write Once, Run Everywhere” in the title. Java, which is also slow and unresponsive, has used this slogan for years. Writing something once, and running it everywhere often comes with a price and when that price is user experience, it often isn’t worth it. Is it worth having millions of users pissed off at your unusable product just so you can cut a few developers or so your developers can feel better about having non-redundant code? Facebook can easily afford to have a small team of iOS developers, a small team of Android developers, and a web team for dumb phones. This would have allowed them to keep the best user experience for each operating system until HTML5 was ready enough to support an equal or better user experience.
Yesterday I traded in my Jetta for a 2012 VW Tiguan SEL 4Motion. So far, I love it. It is a little bit different getting use to a gasoline engine again after having a diesel for a couple of years. I am excited to drive it to southern Minnesota this weekend. Click on the images for a larger view.