iOS Quick Tip – Avoid combining animations with setMasksToBounds, if possible

For Random Dice Roller, I wanted to have pretty looking buttons with rounded corners. If you google for something like ‘ios custom button with rounded corners’, you’ll find various examples that use setMasksToBounds and a corner radius, like this:

[button.layer setMasksToBounds:true];
[button.layer setCornerRadius:4.0f];

This was my initial approach, and it worked flawlessly. My button corners were perfectly rounded.

However, when I added animations into the mix, things didn’t quite work out so well. There was a noticeable lag when animating my screens full of buttons with modal-segue-style transitions. I tracked it down to the call to setMasksToBounds. With setMasksToBounds set to false, the animations were liquidy smooth, as expected. But turn it on, and things get choppy.

I didn’t want to release an app with noticeably choppy animations, so I started looking for a solution. Turns out that it’s ridiculously easy to solve the problem – just use a transparent .PNG with the corners already cut out!

Check out my sample project to see the difference in performance.

If you run it on the simulator, it will appear to work fine; run it on your device, though – in my case an iPod Touch 4g – and you will see some significant choppiness.

The moral of the story is that setMasksToBounds can cause performance issues, and if you can avoid it, you should.

Attention Trackback Spammers

Your spam is being blocked. Please give up and go bother someone else’s blog.

This blog has been the target of a few hundred spammy trackbacks over the past week. Thanks to the ‘Simple Trackback Validation with Topsy Blocker’ plugin, none of it is getting through.

Anyone have any good tips on how to avoid being the target of spammers?

iOS App Postmortems – Random Dice Roller

Random Dice Roller, April’s 2nd app – or May’s first app, depending on how you look at it – is now out the door. As always, it’s time for another postmortem.

Development Time:

  • ~16h

Review Time (time spent in the iOS app submission queue):

  • 9 days

New technologies I learned and used:

  • The main new technology here was networking. This was my first iOS app that touched the network in any way, shape, or form. Aside from the incredibly annoying extra-long default timeouts, it went quite smoothly, and resulted in my open-source class ReallyRandom.

Challenges:

  • I ran into some performance issues when using setMasksToBounds: to round the corners of UIButtons. This will likely be the subject of a blog post in the near future.
  • Taking good pictures of dice is hard!

Future plans: I have quite a few plans for Random Dice Roller. So many, in fact, that it was a difficult decision to actually release it, instead of spending more time adding new features. But in the spirit of release early, release often, I decided to let it go sooner rather than later.

There are two things that will likely be coming at some point in the future. The first one is the ability to roll multiple sets of dice at once; that is, instead of just being able to roll something like 3d6, you could roll 3d6 + 2d8 + 1d4 all at once. This would be quite handy for those games of D&D.

The second one is in-app purchases of different dice sets. I’m not sure what exactly the market would be for that, but I figure it’s worth a shot.

As always, please let me know if you have any feature requests or ideas!

iOS Pain Points – iTunes Connect’s “Sales and Trends”

The ‘Sales and Trends’ section is the worst dashboard/analytics platform I’ve ever seen. It’s combination of uselessness and bugginess is unmatched.

Let’s start off with a look at a few of the issues that I’m sure you’ve all seen before. Eagerly awaiting your sales numbers the morning after your app is released? Too bad.

You would think that Apple would at least do some basic QA to make sure stuff displays properly. But, they apparently don’t.

Grammar? What’s that?

The attention to detail is astounding.

But enough of the minor annoyances. The real problem with Sales and Trends is the lack of functionality.

When you select something from the dropdown above, you aren’t selecting a “week” or a “day”. You’re selecting the end period for some arbitrary, unknown date range. Why can’t I simply choose a date range to view results for? Why am I limited to viewing the results for the past X days or weeks, starting at day or week Y?

Why can I only view data for the past few weeks? Apple is one of the richest companies in the history of the universe, but they can’t even spend a few fractions of a penny on a few extra bytes of storage for historic data?

Why can’t I filter the results by product?

Why does it always show me ‘Free Apps’ by default, instead of remembering that I was previously on the ‘Paid Apps’ view, and that every single time I log in, the first thing I do is click on ‘Paid Apps’?

Why does Apple’s development ecosystem continue to frustrate and disappoint?

App Per Month – 4 Month Review

The blog has been around for about four months now, so I thought it would be nice to do a little retrospective of what happend, and a look at what’s to come.

I have released 3 apps so far: BBQ Menu, PhoToDo, and Feeling Blue?. Sales have not been stellar, but they have been slowly improving.

Website traffic has been consistently increasing, which is quite encouraging.

My most popular post, by far, has been Filtering a UITableView with a search bar. It accounts for a significant percentage of the blog’s traffic.

And as for 2012’s goals? Let’s have a look.

  • Sign up for the iOS Developer Program *Complete!*
  • Release my first app to the app store by the end of January *Slightly late, but close*
  • Release some open-source Objective-C code *Complete!*
  • Start answering Objective-C or iOS questions on Stack Overflow *Complete!*
  • Blog at least twice per week *Slightly behind schedule*
  • Come up with 10 legitimate ideas for App Store apps *3 down, 1 in development, a few more ideas in the works*
  • Implement and release one of those 10 ideas every month or so *On track so far*
Not a bad report card so far, I think. Here’s hoping 2012 continues to rock!

ReallyRandom – an Objective-C class for retrieving truly random numbers from http://random.org

One of my goals for the year was to release some open-source Objective-C code. I am happy to say that I nave now accomplished that goal!

ReallyRandom is an Objective-C class for retrieving truly random numbers from http://random.org. It supports synchronous and asynchronous operation and offers much nicer timeouts than the standard 30 second or 240 second timeouts. I know this class might not exactly have widespread appeal, but maybe someone will find it useful one day. You can get the code from GitHub.

I wrote this class as part of my latest app, which I hope to complete by the end of April. After all, I have to live up to the ‘App Per Month’ name, don’t I?

As I am still an absolute beginner when it comes to Objective-C, I would love any feedback on coding style, best practices, and API usage.