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?