If you're an iPhone 4 owner or 3G[S] user eager to upgrade your OS but you use your iPhone on a non-AT&T (GSM) carrier, good news: The iPhone Dev-Team just released the ultrasn0w 1.0-1 unlock for the iPhone 4 baseband and several of 3G and 3GS baseband versions. The video above walks through the relatively simple unlocking process. As always, proceed at your own risk. [Dev-Team Blog via Engadget] More »
Monthly Archives: August 2010
Unlock Your iPhone 4, 3GS, and 3G with iOS 4 for Other Carriers [IPhone]
How to Migrate Your Entire Google Account to a New One [Data]
Whether you finally decided to shed sassyhacker957@gmail.com for a more professional handle or you want to swap Google accounts for less embarrassing reasons, Google doesn’t have a built-in system for migrating your data to a new account. So we figured it out. More »
Make an Effective Fruit Fly Trap with No Tools [DIY]
If you want to get those annoying fruit flies out of your kitchen without any heavy engineering, this simple trap uses stuff you already have in your kitchen and requires no cutting, taping, or other DIY tinkering. More »
Jailbreakme.com: Jailbreaking Made Absolutely Painless
I admit to being pretty spineless when it comes to using unauthorized software on my iDevices, but recent posts regarding the continued value of jailbreaking such devices had me thinking about getting over my fear and making the leap. As if on cue, Jailbreakme.com 2.0 comes around to make it easier than ever to indulge that particular whim.
In case you haven’t heard, jailbreakme.com is the resurrected version of the original website, which allowed you to jailbreak devices running iPhone OS 1.1.1. It’s back again, and this time, it’s ready to take on iOS 4.0 and 4.0.1 on all iPhone and iPod Touch devices, and iOS 3.2.1 on the iPad. It all happens from your device’s Safari browser, without requiring a computer at any stage during the process.
The new jailbreak process comes via comex of the Dev-Team, and I can attest from personal experience that it makes things impossibly simple. I have an iPhone 4 and an iPad, but there’s no way I’m risking the warranty on those two beauties just yet, so I dusted off the old iPod touch 1G that got me started on iOS devices and put that to the task.
On the iPod touch, I booted up Safari and pointed the browser at www.jailbreakme.com. You should see a screen that looks like this if you’re in the right place (shot is from my iPhone 4, since it changes after you finish the process):

After that, I followed the directions on-screen and left the house to run some errands. I was probably gone for about an hour, so I’m not sure how long the process took, but it was done by the time I returned. My iPod touch was plugged in at the time just in case, but the battery is quite old. I think it should be fine to leave newer devices unplugged.
After the process is complete, you’ll see a message congratulating you and informing you that the Cydia store app is now on your desktop. Finally, launch Cydia and allow it to update its repositories and sources, then browse for the apps you want to install. Backgrounder, SBSettings, BossPrefs and ProSwitcher are good places to start if you’re not familiar with the jailbreak landscape.
The new jailbreak method uses an exploit in the way iOS handles Adobe PDF files, of all things, so basically you can thank the Flash maker for your newly jailbroken device. If anything goes wrong during the jailbreak process, you can restore using your computer, or by putting the device into DFU mode if all else fails, and try again. Cydia has been running a little slowly the past few days, presumably because so many are using this method, so be patient if you’re experiencing problems post-jailbreak in that area.
Anyone else done it yet, or planning on doing it? What about on newer devices? Still worth it?

Trillian 5 Beta is a Streamlined Messaging Client with Much-Improved Looks [Downloads]
Windows only: Trillian 5 Beta is a very slick-looking multi-chat client, and it makes being signed into 10 networks at once seem manageable. If you’re one of Trillian’s many fans, you owe yourself a test drive of this new version. More »
Core Data Odds and Ends
I’ve been doing a fair bit of work with Core Data lately, and have picked up a few tricks to make my life easier, so I thought I’d share.
Mo’ Power
Back in the EOF days, there was a great little piece of third-party software called EOGenerator that implemented something called the generation gap design pattern. Essentially, this little program would create your custom subclasses of EOGenericRecord (EOF’s equivalent of NSManagedObject) for you. It wouldn’t just create that, though, it would actually create two classes for each entity in your EOModel.
One of these two classes was yours to modify as you saw fit. It would never get overwritten even if you ran the EOGenerator script again, over and over. The other class contained all the generated code derived from your EOModel and was designed not to be touched by the programmer. You had your class, EOGenerator had its class, and you could both work without any fear of stepping on each other’s toes. You could add attributes and entities to your data model and regenerate the machine-readable classes without any chance of losing your custom validation or methods. It was nice.
Wolf Rentzsch has re-implemented this idea for Core Data, and the result is called MOGenerator. If you spend any time with Core Data and aren’t familiar with MOGenerator, go become familiar with it. It will make your life much, much, much better.
SQLite to Check Data
The default persistent store type for Core Data under iOS is a SQLite store, which means that Core Data keeps all of its data inside of a single SQLite database in your application’s /Documents folder. Now, the format of the persistent store is undocumented and you should never, ever, ever, ever, never change data in the persistent store or make any assumptions about how Core Data stores the data. That’s part of why we use Core Data: It’s an abstraction layer that lets us not worry about the underlying storage details.
But, sometimes, it can be really helpful to know whether data is getting into the persistent store or not. I often work on my data model before my user interface, so being able to peek in the data store to make sure all is well is really helpful.
The first thing you might want to consider doing, if you plan to do that, is to create a SQLite config file. This is a file of commands that will execute whenever you launch SQLite. To do that, simply create a file called .sqliterc in your home directory. Here’s what mine looks like:
.mode column.header on.table
In mine, the first line tells SQLite to print the column names when I issue a SELECT command. The second line tells SQLite to present the data in tabular form. The last line prints out a list of all the tables in the database before it shows me the SQL command prompt. That’s handy given that the table names don’t usually exactly match your entity or class names.
Once you have a config file in place, you can open up any persistent store using the sqlite3 command in Terminal.app, like so:
sqlite3 MyApplication.sqlite
You can’t, of course, execute this directly against database files on your phone, but you can do it in the simulator as well as on files copied from your phone using Xcode’s Organizer. If you’re using the simulator, you can look for your SQLite databases at the following location:
/Users/[your account name]/Library/Application Support/iPhone Simulator/[SDK version #]/Applications/[application UUID]/Documents/[Application Name].sqlite
When I log into a database with my SQLite config file, this is what I see:
-- Loading resources from /Users/jeff/.sqlitercZHERO ZPOWER Z_METADATA Z_PRIMARYKEYSQLite version 3.6.12Enter ".help" for instructionsEnter SQL statements terminated with a ";"sqlite>
Notice that it has dumped the names of all my tables. It’s pretty easy to figure out which table holds what data once they’re right in front of you. The example above is the persistent store from the SuperDB application from More iPhone 3 Development. The Hero entity managed objects are stored in ZHERO and the Power entity managed objects are stored in ZPOWER. To look at the contents of a table, you just need to execute a SQL SELECT command. The simplest is just SELECT * FROM TABLENAME;, which prints the entire contents of the table to the console, like so:
sqlite> select * from ZPOWER;Z_PK Z_ENT Z_OPT ZHERO ZSOURCE ZNAME ---------- ---------- ---------- ---------- ---------- ----------1 2 2 1 Mutation Fire sqlite>
The format of the data is pretty easy to figure out but, again, you really should look and not touch. It’d be very easy to accidentally destroy a persistent store. A seemingly inconsequential change could get the metadata out of whack and prevent your app from using the persistent store any more.
Better Descrption
I noticed a few days ago that Wil Shipley was complaining about the fact that many of Apple’s delivered UIKit and Foundation objects have not overridden the -description method. This method is important because it’s the one that is used in format strings, NSLog(), and when you type the po command in GDB. Instead of getting a meaningful description of many delivered objects, you instead get the class name and memory address of the instance, which is what NSObject‘s implementation provides, which isn’t very much help while debugging.
Unfortunately, NSManagedObject is one of the many, many classes that doesn’t have its own meaningful implementation of -description. That doesn’t mean you can’t provide one, though.
One thing you can do is to create an abstract subclass of NSManagedObject and put the -description method there. If you then subclass this abstract class, all of your managed objects will inherit the method from the abstract class. If I have other common functionality, I’ll often do exactly that. But if I don’t (and often you won’t) I personally hate to clutter up my object hierarchy to add debugging tools. So I actually will cheat and do something you’re not really supposed to do, which is override a method using a category. The reason it’s bad to do this is because the Objective-C language does not specify which method should be used, which can lead to unpredictable behavior. But, when a class inherits a method from a superclass, I’ve found that overriding it in a category always works. I’m not suggesting you should do this in a shipping app, however. I wrap my method in pre-compiler definitions so that it doesn’t get compiled into the release version of my application.
My version of -description assumes you’re generating properties for your managed objects (I always do) and also assumes you’re using custom subclasses (but you are, because you’re using MOGenerator, right??). The method iterates over all the properties of the class and all its superclasses up to NSManagedObject, then prints them to the console. The categories I use look like this:
#if DEBUG@implementation NSObject(MCManagedObjectDebug)+ (NSMutableArray *)MCproperties{ NSMutableArray *properties = nil;
if ([self superclass] != [NSManagedObject class]) properties = [[self superclass] MCproperties]; else properties = [NSMutableArray array];
unsigned int propCount; objc_property_t * propList = class_copyPropertyList([self class], &propCount); int i;
for (i=0; i < propCount; i++) { objc_property_t oneProp = propList[i]; NSString *propName = [NSString stringWithUTF8String:property_getName(oneProp)]; if (![properties containsObject:propName]) [properties addObject:propName]; } return properties;}@end
@implementation NSManagedObject(MCManagedObjectDebug)- (NSString *)description{ NSArray *properties = [[self class] MCproperties]; NSMutableString *ret = [NSMutableString stringWithFormat:@"%@:", [self className]]; NSDictionary *myAttributes = [[self entity] attributesByName];
for (NSString *oneProperty in properties) { NSAttributeDescription *oneAttribute = [myAttributes valueForKey:oneProperty]; if (oneAttribute != nil) // If not, it's a relationship or fetched property { id value = [self valueForKey:oneProperty]; [ret appendFormat:@"nt%@ = %@", oneProperty, value]; }
} return ret;}
@end#endif
The +MCProperties method uses the Objective-C runtime to discover and iterate over properties in the class definition, including @dynamic properties that were created at runtime. Because the property runtime calls do not include properties inherited from parent classes, the method acts recursively, iterating up the object hierarchy until it gets to NSManagedObject. The actual -description method simply prints out each of the attributes and the value currently stored for that attribute for this object instance. Once you do this, if you use NSLog() or po, the result is much richer information about the objects getting printed to the console. This version ignores relationships and fetched properties, but it wouldn’t be hard to add those in if you needed them.
iphonedevelopment.blogspot.com
Use JailbreakMe to One-Click Jailbreak Your iOS 4.x Device [Jailbreak]
If you’ve chalked jailbreaking your iOS device up as too complicated JailbreakMe is for you. Simply visit JailbreakMe with your iOS device’s browser and enjoy hassle free one-click jailbreaking. More »
Build Linux Apps from Source with Checkinstall for Fewer Problems [Linux Tip]
Even if you know how to compile software from source code, you often end up with an application that your system doesn't technically know exists. That can mean duplicated apps, file issues, and removal problems—unless you use the checkinstall command. More »
NSOperation Xcode File Template
Although I’m generally averse to using a lot of template or boilerplate code, there are times when it’s handy to have file template beyond those that Apple provides. Something I’ve done a fair amount of lately is to create NSOperation subclasses, and there’s enough work involved with setting up an operation that I made an Xcode file template that contains all that setup work.
This template includes a delegate and a protocol and some private methods for communicating with the delegate. Now, when I have lots of NSOperation subclasses in a single project, I’ll actually move much of this stuff to an abstract parent class or a category on NSOperation, but templates don’t have any way of setting up dependencies, so I’ve made this self-contained and you can do your own refactoring.
I added this particular template under the Objective-C class icon so that it comes up as a new option under the Subclass of popup menu.

You can find the template files right here. The zip file contains the full path to install everything in the correct place, so if you want to install it so that you can use it from Xcode, you would use the following command:
unzip NSOperationTemplate.zip -d /
If you just unzip it regularly, you’ll find the actual files nested several folders down as a result of the path information.
I’ve only touched one existing file, which is a property list that causes the new template to show up in Xcode’s Subclass of dropdown menu. The rest are new files, so installing this shouldn’t interfere with Xcode in any way. But caveat emptor. You do keep good backups, right?
Hopefully this will be useful to some of you. If you have suggestions for making it better, please let me know.
iphonedevelopment.blogspot.com





