iPhone/Obj-C development complicated??

Nibbie
Posts: 2
Joined: 2008.10
Post: #1
I've been using Java for ~5 years now (I am currently a third-year undergrad), and in the last year of school, my classes have introduced me to C and C++. I haven't had too hard of a time with those new concepts introduced in C, however I downloaded the iPhone SDK and I am completely overwhelmed. The syntax is confusing, there are both [sender method] type messages along with standard sender.method() functions... I went through quite a bit of Apple's documentation before I had a meltdown.
Now, did I give up too early? How am I supposed to grasp all of this new information, especially when Apple's documentation seems extremely hard to follow..
Quote this message in a reply
Member
Posts: 67
Joined: 2006.07
Post: #2
Objective-C is odd at first, but if you're experienced in Java, it shouldn't be hard to grasp at all. Still, I'd say the way to go would definitely be getting a copy of Cocoa Programming for Mac OS X, by Aaron Hillegass. Arguably the best introductory Cocoa/Objective-C book out there, and definitely one of the most popular. Plus, if I recall correctly, there are a few places in the book where Hillegass actually says things like, "In Java, you're used to doing it like this, but in Objective-C, this is how we do it."

I may not be an iPhone developer myself, but from what I understand, Cocoa/OS X development and iPhone development overlap quite a bit, so I'd say you'd be better off learning Cocoa in general before moving onto the iPhone.

For other suggestions, see this thread. And I'm sure there are many other threads like that -- search the forums a bit if you want more suggestions.

Since when was "Fred" a placeholder variable?
Quote this message in a reply
Moderator
Posts: 452
Joined: 2008.04
Post: #3
You probably learned java a little bit at a time. Your first projects were pretty small, probably 10 lines or less all in your main method. It sucks going back to it, but I think that's what you have to do when you are learning a new language. Don't worry, it does go a lot quicker, but you still have to start at the beginning.

I've tried to jump into languages from basically nothing but reading a lot about the language, and that's not worked too well for me. Sit down and make simple things, and step it up until you get to where you want to be.

Howling Moon Software - CrayonBall for Mac and iPhone, Contract Game Dev Work
Quote this message in a reply
Moderator
Posts: 613
Joined: 2004.09
Post: #4
It may not be the best idea to jump right into the iPhone waters, you might want to do some Mac stuff first.

Even with 5 years of Mac experience I still had a bit of a learning curve going to the iPhone.

Kyle Richter
DragonForged.com
Twitter: @kylerichter
Quote this message in a reply
Nibbie
Posts: 2
Joined: 2008.10
Post: #5
I wouldn't mind learning Cocoa anyway, seeing as I work on my Macbook Pro and it would be nice to develop applications for it.. Thanks for the advice!
Quote this message in a reply
⌘-R in Chief
Posts: 1,260
Joined: 2002.05
Post: #6
The dot syntax is going to be confusing for anyone new to the language. It's a special bit of syntactic sugar that Apple added that makes your code a little less noisy, but is functionally absolutely no different than the old way.


Previously you had setter/getter methods like so:
Code:
- (void)setSomething:(id)thing;
- (id)something;

And you had to call them like so:
Code:
id thing = [obj something];
[obj setSomething:thing];

In simple code, that's fine and easy enough to read, but something like:

Code:
if ([[[self selectedMovie] audioCompressor] bitRateString]) {
    audioSettings = [audioSettings stringByAppendingFormat:@", %@",
            [[[self selectedMovie] audioCompressor] bitRateString]];
}

It starts to get a little "messy". So Apple came up with this "Property" dot-syntax. It's not to be used for calling generic methods, it's only supposed to be used for setter/getters.


With the new syntax you define the property:
Code:
@property (readwrite, retain) id something;

And can use it:
Code:
id thing = obj.thing;
obj.thing = thing;

The ugly code above would be slightly more readable:

Code:
if (self.selectedMovie.audioCompressor.bitRateString) {
    audioSettings = [audioSettings stringByAppendingFormat:@", %@",
            self.selectedMovie.audioCompressor.bitRateString];
}



If you see "objectInstance.something = x" that simply is a shortcut for "[objectInstance setSomething:x]".

If you see "x = objectInstance.something" that simply is a shortcut for "x = [objectInstance something]".
Quote this message in a reply
Member
Posts: 254
Joined: 2005.10
Post: #7
Don't forget to read The Objective-C 2.0 Programming Language first to see if you get it. Its free.

Also check out http://www.cocoadevcentral.com for some slightly outdated tutorials.
Quote this message in a reply
Member
Posts: 446
Joined: 2002.09
Post: #8
If you know C, and you're looking to make a game that draws entirely with OpenGL ES then you don't need to go too nuts learning Obj-C/Cocoa. You can also basically ignore Interface Builder...

I knew next to no Cocoa when I started prototyping my first iPhone games. I read Apple's Obj-C programming guide, the iPhone programming guide, and a few of the Cocoa primers/tutorials available online (be sure to read up on memory management). Those docs provide all the info needed to wrap the required Cocoa Touch APIs into functions exposed by plain C headers. The actual game implementation can then be written in C/C++.
Quote this message in a reply
Member
Posts: 94
Joined: 2008.08
Post: #9
I've been donig Java for around 10 years and picked up ObjectC pretty quickly. Its not as pretty as Java, but its not too hard to get your head around.

I found this very useful
Quote this message in a reply
Nibbie
Posts: 4
Joined: 2008.10
Post: #10
it's not complicated at all, I used Aaron Hillegass's book to learn Obj C/Cocoa Development and it was the best book i've read about Cocoa development.
Quote this message in a reply
Post Reply