PMG Digital Made for Humans

My Progress with Objective-C thus far

4 MINUTE READ | May 23, 2012

My Progress with Objective-C thus far

Author's headshot

PMG Advertising Agency, Advertising Agency

PMG Advertising Agency has written this article. More details coming soon.

So here’s the deal. I’ve published one blog post about things I’ve learned about Objective-C but in reality, I wrote that post about two to three weeks ago. I would go on pretending that this next week’s post is actually what I learned in one week after that last post, but let’s face it – I’m not actually going to do that. Instead, I’ll catch you up on what I’ve learned under my mentor, Andrew Strauss, and then tell you my progress thus far.

I’m sure we all can agree that a lot can happen in to to three weeks. In fact, in that time I’ve already had a baby, I finished trying to make the Bro Code app to move on to bigger and better things, and I’m already almost to the point where I can write 80% of an iPhone app on my own.

Let’s tackle each thing one by one shall we?

Yes, yours truly had his first baby and IT’S A GIRL!!! She is absolutely gorgeous and as of this posting, she is about 6-7 days old and already sleeps through the night. Her name is Brooke Abigail Matos and sad to say, but I may have fallen in love with someone other than my wife.

My Baby Girl

I know – for all you How I Met Your Mother fans out there, this would’ve been an amazing app to put out but unfortunately, the app was really only created to teach me the basics behind Objective-C and Cocoa. Challenge accepted! And job well done. We can actually put this little guy to rest until I decide to come back to him on my free time.

So what am I doing now that I laid The Bro Code to rest? Actual work. George reckoned that I should start on another  app for one of our clients that was created by someone else…who’s to argue with the boss?

I can’t tell you how many bugs we’ve found so far, and the sheer amount of UI mistakes as well. To say the least, I believe we’re about a third of the way through the app and we have a 6th of the amount of source files he does. The original author repeats hundreds of lines of code even though with Objective-C, it’s pretty easy to condense all of those lines of code with a couple of simple lines of code. For instance, let’s say you wanted to bring up a loading view in certain methods throughout your app when you make a call to the server:

Instead of writing this code over and over when you want it to pop up…

UIView *loadingView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.frame.size.width, self.view.frame.size.height)];

UILabel *loadingLabel = [[UILabel alloc] initWithFrame:CGRectMake(110.0, (self.view.frame.size.height-46.0)/2.0, 100.0, 21.0)];

UIActivityIndicator *loadingIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(150.0, ((self.view.frame.size.height-(loadingLabel.frame.size.height+25.0))/2.0) + loadingLabel.frame.size.height+5.0, 20.0, 20.0)];

[loadingLabel setBackgroundColor:[UIColor clearColor]];

[loadingLabel setTextAlignment:UITextAlignmentCenter];

[loadingLabel setLineBreakMode:UILineBreakModeWordWrap];

[loadingLabel setNumberOfLines:0];

[loadingView addSubview:loadingLabel];

[loadingView addSubview:loadingIndicator];

[loadingIndicator startAnimating];

[loadingView release];

[loadingLabel release];

[loadingIndicator release];

You can just take the above code, create a UILoadingViewController that is a subclass of UIViewController and implement a couple of methods that do exactly what I wrote above as you write your own code passing certain parameters to change the text, change the color of the loadingView background color, and throw in a couple of typedef enums to create different loadingView styles. Now, every time you have a ViewController that you want to have a loadingView in, you can just change the subclass on that ViewController to your LoadingViewController like this:

#import "yourHeader.h";

@interface YourViewController : LoadingViewController ;



And every time you want your loadingView to show up, just call whatever boolean method you wrote in your LoadingViewController to have it show up like this:

#import "LoadingViewController.h"


  • (void)setLoadingViewHidden:(BOOL)isHidden{ [loadingView setHidden:isHidden];}

Call that method…

-(void)viewDidLoad{ [self setLoadingViewHidden:FALSE];}

Stay in touch

Bringing news to you

Subscribe to our newsletter

By clicking and subscribing, you agree to our Terms of Service and Privacy Policy

Now later on, all you have to do is call on line of code as opposed to about fifteen to twenty to call on you loadingView.