iOS – View Controllers

Marching right along at a good clip this week is Chapter 7 in the Big Nerd Ranch Guide, titled View Controllers. This chapter focuses on putting together XIB (pronounced “Nib”) files programmatically, as opposed to using Interface Builder. Again, this sounds like the long way around to me, but I followed along.

Using View Controllers in the sample HypnoTime App, we switch from a screen with some filler circles to a screen that tells us what time it is when we push a button. Of particular interest to me here is the method by which we added items to the UITabBar, the black bar at the bottom of some applications. For instance, in the iPod app, “Playlists”, “Artists”, “Albums”, etc. appear here.

Again, it seemed less than elegant and somewhat counter-intuitive for the simple act of adding icons to a portion of the screen.

I’m getting antsy to just start cobbling crap together and seeing what works and what doesn’t for my own ideas for iOS apps. That’s how I managed to learn HTML all those years ago in the late 90’s. Unfortunately, this environment doesn’t bode well for that. Because this is such a new platform, a whole lot hasn’t been written that you can easily turn up in a Google search. And because everything is protected by Apple’s NDA’s, Apple’s about the only place you can go to see sample code, which you can’t copy and paste per their Terms of Service. It’s not a friendly environment for just hacking crap together and futzing with it until it resembles something useful.

That’s probably a feature and not a bug, but it’s somewhat irritating to a tinkerer like me. Plus, this isn’t visual enough to support that kind of development. When you’re starting at a blank screen with only a couple resources at your disposal for looking at code, you can’t just start clicking buttons — you actually have to know what to type. It’d be like opening Word and being told, “Write a novel in Chinese”. Technically, you could, but the interface is of absolutely no use to you if you didn’t know Chinese.

iOS – Subclassing UIView

Moving on to Chapter 6 in Joe Conway’s book, this chapter takes us further from previously using UIButton and UILabel to UIView. This is illustrated with the Hypnosister App, which draws concentric circles on the screen programmatically. I have a bittersweet taste towards creating artwork programatically, only because as a Photoshop wonk, I like having an excuse to use it. However, I get that it reduces file sizes and the like. It just seems like a lot of writing just to draw some circles:

– (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions


CGRect wholeWindow = [window bounds];

UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:wholeWindow];

[window addSubview:scrollView];

// Make your view twice as large as the window
CGRect reallyBigRect;

reallyBigRect.origin = CGPointZero;

reallyBigRect.size.width = wholeWindow.size.width * 2;

reallyBigRect.size.height = wholeWindow.size.height * 2;

[scrollView setContentSize:reallyBigRect.size];

// Center it in the scroll view
CGPoint offset;

offset.x = wholeWindow.size.width * 0.5;

offset.y = wholeWindow.size.height * 0.5;

[scrollView setContentOffset:offset];

// Enable zooming
[scrollView setMinimumZoomScale:0.5];

[scrollView setMaximumZoomScale:5];

[scrollView setDelegate:self];

// Create the view
view = [[HypnosisView alloc] initWithFrame:reallyBigRect];

[view setBackgroundColor:[UIColor clearColor]];

[scrollView addSubview:view];

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];

[window makeKeyAndVisible];

return YES;


Again, I’m struggling to fully comprehend the idea behind classes, sub-classes and the act of “subclassing”. I keep trying to relate them back to CSS classes, and I’m not sure that’s an appropriate metaphor, which may be causing more confusion than it should.

iOS – MapKit and Text Input

I’m still working through Joe Conway’s iPhone Programming text and I’m up to Chapter 5. Using an app called Whereami, it guides us through the MapKit framework and how to input text into a field to gather a location name. That portion doesn’t actually work, but I suspect that’s coming up in later chapters.

For now, the app launches and since we’re using the simulator, it locks us into zooming at Apple’s Cupertino campus instead of actually locating where I really am here in Indianapolis.

Up to this point, I can say that I’ve learned things, but I don’t think it’s anything that the book necessarily wanted or intended at any point in time. I’ve learned about a few frameworks and I’m getting the hang of some of the syntax, but the more key items are still foggy to me.

The sheer number of classes, and all their sub and subsequent super classes vex me. They’re so darn many, it’s literally like learning a whole new set of words and the proper grammar along with it. I’ve not run across any resources so far that take the time initially to educate a person about how to efficiently learn them. Perhaps they assume that Apple’s documentation is the right way to do it and there’s just too many to begin with, so it’s a “type it and you’ll figure it out” approach. It doesn’t seem elegant, though.

Here’s How to Learn Spanish

As I’ve been muddling my way through learning about iOS Apps and Objective-C, there’s a familiar testimony among developers on forums and blog posts around the web:

“Objective-C is hard. Start by learning Python or Ruby first, then go with Objective-C.”

The language they cite isn’t always the same, but Python and Ruby do come up a lot.

This is about the dumbest argument I’ve ever heard. Imagine that you don’t know anything about Spanish beyond “El” and “Hola” and you want to learn Spanish. Imagine your teacher saying, “Oh, Spanish is hard. We need to learn French first.”

But you don’t want ┬áto learn French, you want to learn Spanish. How does that make any sense? Sure, some things might be related, but they’re two different languages for pete’s sake!

My conclusion is simple: if you want to learn a language, whether it’s computer or verbal, go learn that language and immerse yourself in it as much as you can. Don’t spend time learning a language you have no interest or need in first just because someone else subjectively thinks it’s easier that way.

iOS – Delegation and Core Location

I spent this weekend immersed in iOS Development stuff. I read chapter 4 of the Big Nerd Ranch guide called “Delegation and Core Location”. I know what that means, per se, just not how to implement it. This chapter had us doing a little coding, but again, I failed to full comprehend what it was I was actually writing or doing. I just took it’s word for it. It keeps saying that will improve with time, but I’m anxious. For one, my 3rd grade teacher, Mrs. Gruesbeck, told my mom, “Someday, math will just ‘click’ for him and it’ll all fall into place.” It clicked alright. Right after my last math class in college where I said, “Glad I scraped by that.” I’m still waiting for the rest of the click.

However, there was some good progress this weekend. For one, Apple released several of their Developer Center PDFs as free eBooks, which I downloaded and started reading religiously. They’re available in the iBooks store. They’re also available, I’m told, in the paid Dev Center, but I haven’t paid my $99 dues to the mothership yet. However, I’m of the belief they’re other guides available there that may be of benefit, such as sample applications. I’ve always learned web technology by just picking apart code, deleting crap and seeing what breaks. It’s a sort of reverse-engineering approach that I take with learning that’s served me well.