I Love You, Xcode
16/10/11 20:32 Filed in: iOS
Auto incrementing build numbers. See what happens when you use a real, Unix-based OS?


Adventures in CoreData
While changing one of my iOS apps to use an NSFetchedResultController instead of a sorted NSArray of NSManagedObject instances (I really like the way it handles sorting and grouping, additions and deletions). Trouble is, the list is manually sortable by the user using the drag controls in edit mode.

The way you do this, of course, is by adding a numeric "sort" attribute to the entity and sort by it. When you move a row, you renumber the rows by their sort attribute.
If you've ever tried to do this with a UITableViewController using an NSFetchedResultController, you'll no doubt be shaking your head right now because you'll know this leads to very strange results. Do a search online and you'll find tons of detailed advice for how to resolve this "problem".
All of it is wrong. Tragically, comically, desperately wrong. Alway, always, always read the documentation first!
It turns out the cause of the odd behavior is very simple; the controller is observing the entities, recognizing changes, and translating them to table updates by calling the delegate methods. Normally, this is exactly what you want. The table will automatically adjust to changes in the fetched data. Except, if the table itself initiates the change, the two mechanisms compete with each other.
The solution to this strange behavior is simply ignore the delegate callbacks if the changes come from the table being edited. Set a flag in the tableView:moveRowAtIndexPath:toIndexPath: callback and if set, bail out of the NSFetchResultControllerDelegate methods.
Just goes to show you; don't trust the Internet. Especially for coding advice.

The way you do this, of course, is by adding a numeric "sort" attribute to the entity and sort by it. When you move a row, you renumber the rows by their sort attribute.
If you've ever tried to do this with a UITableViewController using an NSFetchedResultController, you'll no doubt be shaking your head right now because you'll know this leads to very strange results. Do a search online and you'll find tons of detailed advice for how to resolve this "problem".
All of it is wrong. Tragically, comically, desperately wrong. Alway, always, always read the documentation first!
It turns out the cause of the odd behavior is very simple; the controller is observing the entities, recognizing changes, and translating them to table updates by calling the delegate methods. Normally, this is exactly what you want. The table will automatically adjust to changes in the fetched data. Except, if the table itself initiates the change, the two mechanisms compete with each other.
The solution to this strange behavior is simply ignore the delegate callbacks if the changes come from the table being edited. Set a flag in the tableView:moveRowAtIndexPath:toIndexPath: callback and if set, bail out of the NSFetchResultControllerDelegate methods.
Just goes to show you; don't trust the Internet. Especially for coding advice.
Revamping The Fox & The Grapes
15/04/11 06:24 Filed in: iOS
Zoinks!
I just noticed that The Fox & The Grapes has a bug on iOS 4.3. Besides, I really don't like the audio (narration or music). So I'm in the process of redoing them.
Maybe I can add a few features to it, too.
I just noticed that The Fox & The Grapes has a bug on iOS 4.3. Besides, I really don't like the audio (narration or music). So I'm in the process of redoing them.
Maybe I can add a few features to it, too.
Ugh, Web Site Drama
13/03/11 13:56
So my web site was basically down for a week thanks to my old domain registrar. It took them a week to approve the domain transfer and parked my domain at a freakin' spam landing page in the meantime.
Nice way to make sure I'll never, ever use them again for anything. Ever.
On the other hand, Hover.com is great. Use them. They don't suck.
Nice way to make sure I'll never, ever use them again for anything. Ever.
On the other hand, Hover.com is great. Use them. They don't suck.
Converting a PDF to Text
22/02/11 06:35
Here's an Automater service for PDF files that will turn them into rich text files. It's really just a wrapper around the "Extract PDF Text" action, but hey, now I have it right in the context menu of any PDF. I love OS X!
Convert to Rich Text Document
Convert to Rich Text Document
