Pinbook 1.2.1 is out now on the App Store, adds support for sending to Readability (if Readability’s app is installed), and fixes these issues:
- Delete not working properly when searching.
- Tags and date overlapping in bookmark rows.
- The description screen appearing blank when editing or creating bookmarks.
- A crash that could occur when editing certain bookmarks.
- Media auto-playing when viewing a bookmark (like if you saved a link to a video).
I also learned a couple of development related things during this update that I think are worth mentioning.
Using URL Schemes for UIActivity Subclasses
The one new feature I’ve added is sharing to Readability for people who have their app installed. Instead of trying to implement something using Readability’s API, I just wrote my UIActivity
subclass to use their apps URL scheme to send whatever URL.
I think it’s a pretty fair assumption that if someone really wants to send a URL to a service like this, they probably have the app installed. It also means that Readability users don’t need to go through the hassle of typing in a username and password for pretty much no benefit. The other advantage of doing things this way is that if in my UIActivity
subclass I return NO
from -[UIActivity prepareWithActivityItems]
, UIActivityViewController
will automatically hide that option without me having to do anything different my view controller. This means that I can check -[UIApplication canOpenURL]
, and the option won’t show up for users without Readability installed. The code might look something like this:
- (BOOL)canPerformWithActivityItems:(NSArray *)activityItems
{
NSURL *readabilityScheme = [NSURL URLWithString:@“readability://“];
return [[UIApplication sharedApplication] canOpenURL:readabilityScheme];
}
Code Cleanup and Maintenance
I did a lot of code cleanup during this release: trying to refactor things to be more orthogonal1, and remove code that wasn’t serving a purpose anymore. I’d classify the code in Pinbook as very clean, but I also know that it will only stay that way if I keep on top of it. It’s the kind of work the user doesn’t see, but if it let’s me continue to put out updates quickly and keep them bug free, they’ll benefit from it.
One example is that I improved the way that Pinbook checks if it needs to update. The way that Pinbook knows that it needs to update is it asks Pinboard for the last modification date, and gets back some XML that looks like this:
<?xml version=“1.0” encoding=“UTF-8” ?>
<update time=“2011-03-24T19:02:07Z” />
Instead of actually parsing the date out of this, what the app was doing was just checking if the entire thing had changed and comparing it to whatever we got back the last time. In the new version I’m pulling out the date and using actual date comparison methods to check it against the last seen update time. It’s a part of the app that I don’t know of causing any issues, but it made me uncomfortable because the approach was lazy, and I was afraid it might have caused an issue for someone I didn’t know about.
I think the reason this didn’t get fixed earlier was that I probably wrote it quickly during development just to get something working, intended to clean it up later, and never did. It’s a lesson for me that if I know how something should be done, I should do it that way upfront instead of saying that I’ll clean it up later, and possibly get side tracked.
- Yes, I’m reading “The Pragmatic Programmer” right now. ↩