Posts

Vim Search for Tags File

I use ctags with vim. This works great when the tags file is in the same directory as the files I'm working on, but is a chore when projects have nested directories. Add this to your .vimrc file and the recursive search up the directory structure will be done for the tags file: set tags=tags;/

Why Hydrate Yourself?

This is a short essay about why I decided to create " Hydrate Yourself ". It is a free app for the iPhone, iPod touch and iPod which tracks water intake and helps encourage a healthier lifestyle. According to webmd.com [ 1 ] and the US National Library of Medicine [ 2 ], symptoms of dehydration include: Dizziness, Lethargy, Lightheadedness, Headaches, Fainting, Weakness and (naturally) a Dry mouth. Other symptoms even include heart palpitations (that feeling of your heart jumping or pounding). So why is it that water intake is such a secondary concern to so many adults? All it takes is a little attention throughout the day, such as keeping track of how much water you are drinking or carrying a water bottle with you at all times. I strongly believe that drinking enough water is one of the easiest ways to improve your health. But how much water is enough? Its hard to say, since so many foods we eat every day contain water. Common "rules of thumb" include 8-10 gl...

Fetching a large data set with Core-Data

I needed loop over a potentially large set of data stored in Core Data, but did not want to force the system to load the entire data set in memory or have Core Data constantly process faults. There seem to be several ways to do this, some easier than others. One robust way would be to use an NSFetchedResultController , but it looked a little more complex than I wanted to deal with ( and involves implementing yet another protocol). After poking around the NSFetchResult class page for a while I noticed these methods: setFetchLimit and setFetchOffset . It turns out that these are just like the LIMIT and OFFSET keywords in SQL, which is just what I was looking for. Using this method is just a few extra lines of code. This is what it looks like:

Custom UISwitch to show YES / NO

Image
You can see this in action in my free water tracking application " Hydrate Yourself ". If this helped you please consider downloading it and leaving a review. One of the great things about iPhone development are that there are lots of user interface pieces that are easy to put together and customize. Unfortunately there are also a lot of pieces which don't have all the basic customizations that may people want. The UISwitch is one of those. Here is the standard UISwitch: Its size, colors, and ON / OFF text are not changeable. Fortunately there are several great re-implementations (and a few hacks that use restricted API calls) to modify all this. One that I am using is the RCSwitch class available here . I made two small changes to this code, first I renamed his RCSwitchOnOff class to RCSwitchYesNo and changed the labels to YES / NO. Second I added an init method to the RCSwitch.m base class which called the usual init function but provided the default frame size....

UITableView which is its own Delegate and DataSource

I spent some time tonight working out a simple class which extends UITableView and conforms to its own protocols. If you are just learning about UITableViews they can seem a little daunting, but like so many other pieces in the iPhone toolbox they are very easy to use once you get the hang of it. If you add a UITableView to your root view it will be a box with some lines across it and you can make them move by touching and dragging in vertical gestures. In order to respond to the touch selections you must set a delegate to the class, just like any other object (Like UIButton or UISwitch). There is a second delegate called "dataSource" which is used to populate the table "cells". The delegate class must conform to UITableViewDelegate and UITableViewDataSource.

Taking Stuff Apart: Coffee Machines

Image
These are some broken coffee machines I've had hanging around for a while. The cheapest Mr. Coffee that Walmart sells and some fancy Morphy Richards coffee/espresso machine. The fancy one was from my first and only Woot Bag of Crap - they sent me a broken coffee machine. Rather than throw them in the dumpster I decided to take them apart then throw them in the dumpster. Here they are:

This Way Up: First App Submitted

Image
Free Version and Ad Free Version I've submitted my first app to the app store. The process was fairly easy. Hopefully a couple people will find it and be amused. At 99c this app which uses the magical iphone accelerometer is certainly a bargain. Here is a video: