iOS Development Link Roundup: Part 1

I’ve often been asked by people about where to start with iOS programming, whether they be co-workers, colleagues in the same line of work at other companies, or even total strangers who happen to see me happily working away on my personal projects in Xcode. Some rather naïve people assume that I learned from a book, still others even think I took a class to learn all of this! I can say definitively that it’s in my opinion that to be a great iOS developer, you just need to write apps, and lots of them. Experiment, try different things out, and more importantly, buy a few really good iPad and iPhone apps so you can see for yourself the design patterns that make good apps, and those that make poor apps.

More than that however is knowing how to implement tiny techniques. It’s the tips to get you started on animations or laying out UITableViewControllers, or perhaps how to do that tiny bit of custom drawing you need. It’s also the libraries and 3rd-party modules that fill in the gaps in Apple’s SDK, such as handy progress indicator alert classes, or easy-to-use async HTTP libraries. Knowing a few key points can take you a long way toward building your first few apps, and in the process you’ll learn more than if you were to take a class.

I usually keep my bookmarks organized using Delicious.com, being one of their early adopters (back when their domain was del.icio.us). Check my iPhone tag on Delicious to see my full list of links that I found bookmark-worthy. For a more decisive list that isn’t sorted chronologically, here’s my breakdown of some of the better sites to find information on iOS mobile development. Continue reading “iOS Development Link Roundup: Part 1”

Fun shadow effects using custom CALayer shadowPaths

Shadowed view using a rectangular shadowPath

I recently had to improve the performance of a few views that utilized CALayer-based shadows on rounded-rect UIView objects. On this particular iPad application, when the device was rotated, the views rotated quite a lot slower than we would have hoped. It wasn’t a show-stopper, but the jerky rotation animation made it look cheap and unpolished. The easiest way to have our cake, and eat it too, was to set a custom CGPath to the layer’s shadowPath property. This told UIKit to set the inside of the path to opaque, reducing the amount of work the rendering engine needed to perform.

// Add background tile
UIImage *bgImage = [UIImage imageNamed:@"embedded_bg.png"];
self.view.backgroundColor = [UIColor colorWithPatternImage:bgImage];

// Add the reference view
UIImage *image = [UIImage imageNamed:@"dccp.jpeg"];
UIImageView *imgView = [[UIImageView alloc] initWithImage:image];
[self.view addSubview:imgView];
imgView.center = self.view.center;

imgView.layer.shadowColor = [UIColor blackColor].CGColor;
imgView.layer.shadowOpacity = 0.7f;
imgView.layer.shadowOffset = CGSizeMake(10.0f, 10.0f);
imgView.layer.shadowRadius = 5.0f;
imgView.layer.masksToBounds = NO;

UIBezierPath *path = [UIBezierPath bezierPathWithRect:imgView.bounds];
imgView.layer.shadowPath = path.CGPath;

[imgView release];

The resulting image, as you can see above, has a shadow as you’d expect. But since we’ve declared the shape the path will have, the iPad can drastically improve its rendering performance.

Through that process however, I decided to see what sort of effects I could pull off by passing in a path other than the default rectangular bounds of the layer. Since you can create any sort of path you want, I considered the different effects I could get away with by making non-rectangular paths and using them as shadows. Continue reading “Fun shadow effects using custom CALayer shadowPaths”

Allergies, and why Kimpton Hotels Rock

As some of you may be aware, I have enough allergies to various common foods to have earned the name “bubble-boy” from my friends. In fact, my wife’s friends used to semi-joke about me while we were first engaged that she should take a good life-insurance policy out on my, “just i n case”. She used to laugh at that, until she had to race me to the hospital a couple times, or stay up all night to make sure I didn’t stop breathing. Now it’s not a laughing matter. Now she’s paranoid for me wherever I go, always carries a spare epipen with her, and arranges our travel schedules around flights and hotels that can accommodate allergies. Continue reading “Allergies, and why Kimpton Hotels Rock”

Rendering views using CALayer, Part 1

For myDrumPad the main pad buttons are images. I create a UIButton object, and use setBackgroundImage:forState: to customize which image will be used for each state (UIControlStateNormal and UIControlStateHighlighted mainly).  I customize the title label font, shadow and color, and voilà I have a pad button that simulates the look and feel of  a Korg padKONTROL. There’s just a few small problems with it.

  1. The images on the iPad are fairly large, and memory is at a premium.
  2. The size of these buttons can change in portrait vs. landscape. It’s time-consuming to export different versions from Photoshop for the different orientations.
  3. The buttons are sized differently depending on the size of the button grid (e.g. a 3×3 grid of buttons have larger images than 4×4 or 5×5 grids). If I resize these images on-the-fly, then the edges look blurred and aren’t well-defined.
  4. The retina display complicates all of this, meaning I have to have two versions of each image.
  5. I want to be able to customize the buttons to have different colors when you’re on different drum sets.

Because of that long list, simply using an image isn’t good enough. But instead of drawing my images using regular Core Graphics drawing routines, I’m going to use Core Animation Layers, or CALayers, to accomplish the same thing. Ultimately I want my buttons to be able to be animated, to change color, and to feel more “alive” than a static image could accomplish. Continue reading “Rendering views using CALayer, Part 1”

Even geeks forget their passwords

Passwords are definitely fickle beasts.  I’m used to juggling a multitude of different semi-incomprehensible passwords containing a mixture of numbers, symbols, upper and lower-case letters, and in some cases unicode characters (letters such as ü, • and §). And for some mysterious reason I’m able to remember these gibberish-filled passwords with ease. But despite all this, when asked to input a 4-digit passcode into my iPhone to be able to lock my phone (a requirement for hooking it up to my company Exchange server), I couldn’t keep that simple password in my head for longer than 8 minutes.

Can you believe that? Numeric passwords are perhaps the easiest passwords to crack. There isn’t enough variance in the values each character can hold to guarantee uniqueness or complexity to be considered secure, yet for some reason bank ATMs and cellphones use them with impunity. Perhaps my problem is I’m so used to being security-minded, that something as simple as 1234 didn’t occur to me.

So now I’m waiting for my iPhone to restore so I can recover my device (luckily I’d backed up just prior to adding my Exchange email account).  But once I finish with this, I’ll have to do the same thing for my iPad with its 12 gigs of WWDC videos; I’m not looking forward to that.

Update: After wiping and restoring my phone from backups I was able to get at the phone without a lock code. Success! Once I checked my Exchange email again, it required me to specify a new pin code. I made sure to type something in that was really easy to remember. Something with a couple 1’s and a 5 or something. I’m not quite sure because after going upstairs for dinner, I came back downstairs and discovered I could no longer remember my new password. I’m restoring from backups yet again, and hopefully this time I can come up with a password I can remember longer than a goldfish can remember a password.

Boomle, the underdog of my iOS apps

Boomle is by far the lowest-selling app I have published on the iTunes App Store, and sadly as a result I just haven’t had the motivation to dedicate more time to it. However it’s times that I see people using it in person that I see just how much people enjoy playing it. I really hope I’ll have time to revisit it, because it’s one of those games that people just “get”, and is enjoyably challenging throughout the whole game.

Most anyone reading my blog won’t know what the game is, so let me explain a little.  Boomle is a relaxing game featuring balls bouncing around the screen.  They move slowly and peacefully, but if you tap anywhere on the screen you set of a small explosion.  If it encounters any of the floating balls, the ball it comes in contact with will explode as well.  This causes a chain reaction, detonating any other balls in their path.

The goal of the game is to eliminate a minimum number of balls per level, but extra points are awarded if additional balls over the minimum requirement are exploded.  And when each ball explodes, it makes a chiming musical sound.

Most people using the game for the first time will:

  1. Instinctually tap in the center of the screen;
  2. Try to tap directly on a ball, instead of in empty space (but in a place where a ball will travel to);
  3. Try to tap more than once to set off more explosions per level (which isn’t permitted).

My hope is that I can improve on the game to take advantage of the default actions people find most familiar or intuitive.  For instance, add a better scoring system that can keep track of your score over time.  When you have enough of a score you can get a second “bomb” to blow up in your level.  Each new level will give you a new bomb to detonate, but if you do well, you can acquire more bombs that you can use up on some pesky levels.

Another thing I’d like to add is an initial “Tutorial” level that has some text overlays to show how to play the game.  And to make the game more challenging, and to allow for more than the current 11 levels, I’d also like to add obstacles to make the bounce pattern of the balls inconsistent, or special balls that you should avoid detonating.

Unfortunately because of the way the game is built there are a few minor bugs, but more importantly the way the code is written makes it difficult for minor refactors.  In fact, I’m fairly certain the game will need a complete overhaul or maybe even rewrite in order to improve upon it.

In light of my limited time to work on my personal projects, as well as the aggressive roadmap I have for myDrumPad, I doubt whether I’ll have any time in the next few months to work on Boomle. Normally I’d just chalk a project like this up as a failure (the app itself works, but failed to net any large amount of sales) but since the game is so fun, and everyone I see actively playing the game absolutely enjoys it, it makes me feel guilty for leaving it behind in the dust.

If people were to discover the app and give it a try, I’m sure it would do a heck of a lot better. But due to the app’s poor visuals on the app store, it’s not something most people would try out just for the heck of it. Game Center support might help, as well as a way to share goals and achievements with friends on other places such as Twitter, etc. Beyond that, it seems like the mobile gaming space is just too noisy for a quiet and unassuming game like Boomle to be able to compete.

Blogging every day ≤ Coding every day

My life is pretty darned busy right now. Transitioning to a new job, travel for work, helping @dccp with her travel arrangements for her academic conferences, my own iOS projects, and my blog. Since the time I have available to work on my own coding experiments is limited to evenings and weekends. I’ve been recently attempting to focus on just one or two projects at a time, since for a while there I was coming up with at least 3 new prototypes per week.  Focusing on myDrumPad has really made it easy for me to give it the extra polish and attention it needs to take it to the next level. However, since I started participating in NaBloPoMo, the National Blog Posting Month, this has been consuming a great deal of my free time.

I enjoy writing about what it is I’m experimenting with, things I’ve learned in my iOS development, as well as other random tidbits that most people likely won’t care about. But writing about those activities have begun to overshadow the activities themselves. I don’t understand how prolific bloggers can balance their online writing, their businesses, as well as maintaining a happy family balance – perhaps they don’t?

I’m going to try to see NaBloPoMo through to the end, but what this is showing me is that either I put way too much effort into my blogging, or perhaps I don’t have as much free time as I formerly thought? Maybe it’s the fact that I got more done on the SkyTrain than I previously thought, and commuting in the car these past two weeks have taken more time of my day, but the progress on myDrumPad isn’t what I’d like to see.

How do other bloggers out there balance their blogging activities with their actual lives? Especially technical bloggers that write about iOS app development, web development, databases or scalability?

Revenue Canada wants me to buy an iMac 27″

For as long as I’ve been a developer, there was only ever once when I had a machine that I felt was an adequate development workstation. That was around 2001 when I had a dual-proc 667MHz P3 768MB RAM and three 17″ CRT monitors. This baby put out enough heat that my home-office didn’t need a heater on during the rainy Seattle winters; in fact, it was so warm in there that I’d wear shorts, a tee-shirt, and left the window wide open.

Since that time though, my computer has typically been limited to a laptop, my biggest since that dual-proc furnace being a 17″ Powerbook G4. Being a developer, there are three priorities that stand out above all others: screen real-estate, memory and CPU speed. Due to my history of being a web developer, only the first item on that list was a big priority. Since becoming an iOS developer, where your productivity is directly related to how fast you can compile your app, and how fast your performance profiling tools can run, I’ve encountered the other barriers developers face.

In the past though, I’ve largely been a cheap developer, opting to get by with what I have, or doing whatever I can to improve my productivity in other areas. However, for the first time since that space-heater with a RAID array, I have an opportunity to get the workstation I’ve been dreaming of.

Since I run my own personal business on the side, I can take advantage of tax deductions that normally wouldn’t be available to me. Computer purchases, like other capital expenditures, can be tax deductible, so the money I would have to pay the Government in the form of taxes, can be deducted from what I owe them. Normally only a certain percentage of that purchase price can be written off per year, in a process called amortization, so it’s effects are only moderately felt.

In Canada, as part of their economic stimulus package they put together to boost small business spending, they instituted a limited-time Capital Cost Allowance for 100% tax deductions on computer hardware and software purchases made between January 27th 2009 and February 1st 2011.

Think of it this way: assume I had a decent year of app sales on the iTunes App Store, and because of my extra income, let’s say I owe the Government $10,000 in taxes. Normally my only recourse is to dig up $10k (which, since I’m a good little business owner, has been sitting in a savings account all year long) and hand it over to Revenue Canada.

But because of this stimulus package, I have an option. I can instead buy $4,000 worth of computer hardware necessary to effectively run my business, and then only give $6,000 to the Government. No need to spread that deduction out over several years, no need to have the accounting hassle of carrying that equipment value over year after year. I see, I buy, I save.

There are limitations of course. Just as with other business deductions, you can’t cheat and take advantage of the system for your own profit. At home I use the equipment in support of my iOS development, web development, and any testing I need to do.

So what do I get for my last year?

This is the last year you can take advantage of this deduction, which really is a shame. But now that my side work is taking me to more and more demanding areas, such as Core Audio, OpenGL, and a little bit of video work, I feel that now is the time to invest in that dream machine I’ve always wanted and needed.

The question is, what’ll it be? Do I add on a cinema display to my laptop? Do I get a fully pimped-out quad-core iMac 27″? Or do I splurge and get both?  Based on my preliminary estimates for how much I’ll be owing in taxes, here’s my shopping list:

I’m probably going to wait until mid-December, or perhaps in January when I get back from my various weeks of travel.  What are your thoughts?  And if you’re a Canadian iOS business owner, what are you going to do to take advantage of the capital cost allowance?

Recovering from bit rot

One of the things that’s hard as a developer is keeping your legacy code up to date.  It’s all too easy to fire-and-forget; write your code, debug it just enough so that it compiles, and then forget it until it breaks again.  I’m guilty of that as well.  In fact, just today I discovered that my continuous deployment configuration for Boomle was broken…for the past 3 months.

After merging my code from a private repo over to Github, it still didn’t work.  After updating the Hudson build configuration to point at the proper repos and to respond to the proper webhooks (to get automatically triggered on a new check-in), it STILL didn’t work.  You see, not only does configuration change, but SDKs and APIs shift out from under you.  The iOS SDK had changed out from under my project, and the Xcode configuration was pointing at libraries and SDKs that no longer were shipped by Apple.

The lesson for me here is this: I need to get off my ass every few weeks to at least look at my source code.  Kick the tires a little, hit a build every now and then, and check that everything is still okay.  Because the longer you wait, the more things can fall apart.  Each one of those issues I mentioned above would have been simple to fix, had I addressed them right away.  But the more problems that build up, the more difficult it is to clean up your code.

As it is, I still need to integrate Game Center with Boomle, and refactor its drawing routines to be more efficient.

Now, I don’t believe in New Year’s resolutions.  Instead, I believe in making resolutions whenever they’re relevant, and sticking to them without the excuse of a New Year to motivate you.  My resolution is to take care of my projects proactively, instead of forgetting them.  Treat it like the quasi-living thing that I’m anthropomorphizing it to be, because even inactive projects need love too.

Localizing iOS apps using ICanLocalize.com

As with most things, the amount of work we as developers see when starting an iOS application is just the tip of the iceberg. There’s artwork, “About” screens, tutorial pages, icons, the app’s website, and all the marketing the app needs to get it out there. Even writing the app’s description or taking screenshots for the App Store is a time-consuming process. So anything I can do to cut down on the time needed to release my app, the better I am. Therefore when I decided to have myDrumPad translated to other languages to widen my user-base, I wanted to do make it as painless as possible.

I tried tried to have friends and family who understood foreign languages help with translations, and while they were very well intentioned it really didn’t work out in the end.  What I discovered was that there really is no substitute for hiring a trained professional.  But luckily it doesn’t have to be outrageously expensive. Read on for more.

Continue reading “Localizing iOS apps using ICanLocalize.com”