I’m John C Bland II

Husband, Father, Tech Author, Deacon.
Founder ofย Katapult Media, and full-stack polyglot developer.
Political Free Agents Podcast Host.

I create. I launch.

YouTube Channel

I post regular fun on YouTube like me playing the bass and anything else I find fun.ย 

Get Something Built

All project work goes through Katapult Media. Business is open. Let’s chat.

Objective-C: What is .m?

This was a bit odd for me but I just got the answer I wanted.

When you create a class you create a .h (where applicable) and a .m. The .h is your interface. No sweat…seen these before. Hrmm…what does the “m” stand for though?

.m = implementation file

That makes sense. I mean I knew it was the @implementation code but I didn’t know what the “m” in the filename stood for.

Nothing mind-blowing…just blogging a note. ๐Ÿ˜‰

Objective-C: [[Class alloc] init] Alternative

Reading more in the book I found what makes more sense to me in terms of instantiating a class.

My previous post showed this as the way:

MyClass myClassInstance = [[MyClass alloc] init];

…effectively calling the alloc and init methods on the class then the class instance, respectively.

I see now you can simply do this:

MyClass myClassInstance = [MyClass new];

This makes WAYYY more since coming from ECMA where you’d do:

MyClass myClassInstance = new MyClass(); //java and C#
var myClassInstance:MyClass = new MyClass(); //as3

The author suggests still using the two step approach, alloc/init, so you know you are calling two distinct methods. I will probably use “new” instead because it is more intuitive to me.

On Chapter 4 (Data Types and Expressions) now. More to come.

Objective-C: Declaring and Using Classes

Learning Objective-C for me is about learning how to read the code in comparison to other languages I know. Here is what I know so far about classes.

I may say this in all of my posts but this is just weird to me. I won’t get long winded here but I do want to post a few examples. Keep in mind I’m posting these as I learn so there is a lot of knowledge to be had. With that said, you might see me do a part 2 of this post clarifying something I may have posted here.
(more…)

Learning Objective-C

I took off on a personal venture to learn Objective-C about a week or so ago. I thought, initially, my old C skills would jump in but it has been 10’sh years and Objective-C is NOT, I repeat, NOT like the C I remember. ๐Ÿ™‚ย  There are tons of resources online but I couldn’t make heads or tails of it so I turned to a book. The problem, as I see it, is with a weirdly structured language and the tons of crappy code online. Call me spoiled (by ECMA languages, that is) but Objective-C is an ugly language. You have unconventional approaches to calling methods, etc. It is not straight forward like

someClass.someMethod(someParam)

Instead,

[someClass someMethod: someParam]

HUH??!?!?!? ๐Ÿ™‚

There are a plethora of Hello World examples online but most of them deal with it on the iPhone or a native OSX app. This is a fundamental problem of learning languages, IMO. Most times we start with the “frameworks” vs looking directly at the code so we get caught in the mix of things. I realized I was doing this exact thing, trying to learn Objective-C while learning iPhone dev, so I thought back to how I learned Java and C#: I read a core book detailing the language intricacies. Well…Java was a design patterns book then I took a training while at Limelight which helped. Either way…started with a book. ๐Ÿ˜‰ So I found a book on Objective-C, not iPhone or OSX, and bought it on my Kindle. It touches on them but most of the book is about straight Objective-C code in a terminal window.

So far I believe in this book. It is showing me a lot and, most importantly, it discussing the fine details of the language. Kudos to Stephen Kochan. My plan is to post all of the intricacies here to detail the differences between Objective-C and ActionScript, C#, or Java. I might talk about all three on one posts but might only hit one. Those three are all ECMA so posting about one will be pretty close to posting about the others anyway.

Look for some posts coming soon.