Tag Archives: count

Core Data helper – REVISED

After my initial post regarding the the modified Core Data helper (by Björn Sållarp in this article) I decided to alter it to be a bit more helpful, so I added a few more methods to perform some commonly required tasks. You’ll find the revised class at the bottom of this article. Here are the new methods and examples of how you would use them. For completeness I’ve included the original methods too. The error checking for all the methods has been changed and should be working correctly (they don’t do anything – but you’ll be notified if something didn’t work and can write your own handling). So… after including the class in your file you can do the following… Continue reading

Making a count indicator

Count indicator exampleJust recently I wrote a list app for iPhone, so I could maintain lists with items in them.  I wanted to jazz it up a bit by using a count indicator similar to the one you see in the mail app, which shows you how many messages you’ve had from someone (you know the one… the little bubble with a number in it).  Anyway, turns out that Apple don’t provide a mechanism for this so I wrote my own one.  You can see it over there to the left (a little gray bubble with a count in it) and this post basically shows you how I achieved it (with code and an example project).

All it’s essentially doing is using Core Graphics to draw a line. That’s all. One line, except to get the rounded ends I’m using a cap as demonstrated in many of the Apple examples. I thought this was easier than figuring out how to round it off manually. Then I take the text and paste it as close to center as I can.

Now it’s not perfect I know… changing the font size doesn’t always vertically align the number properly – but it does look nice enough, and I’m sure someone can make use of this even if a little tweaking is required.  At around 14 point font size it looks good….

Continue reading