Google
 
Web www.howardforums.com
Pages: 1

So.. this looks harder than I thought.

(Click here to view the original thread with full colors/images)


Posted by: dingobiatch

I'm coming from Java/C# (I'm about to take a course in C/C++), but this Objective-C stuff looks ridiculous. Brackets, properties, NS stuff?? Is there any place that would help me figure this language out? I'd love to develop a decent applications for the iPhone but even looking at the basic template programs freaks me out.



Posted by: BeyondTheTech

I'm kinda intimidated about the Objective part myself. From Instance Variables to Methods to Classes, it's really feels like a challenge. However, if you check out the sticky with the online manuals, especially the one I posted, it'll give you a dumbed-down look at dealing with Objects that may help take the edge off. I printed a lot of these out and read them on my commute to work. Good luck and see you on the other side!



Posted by: dizzyj

ya, been reading the objective c stuff. I come from a c++ world and its similar, but the syntax is all funky.

apple did good tho, I've got me a shiney new macbook pro to code on as of today



Posted by: BethanyBoo

I normally don't have much of a problem switching between languages... is it that hard to learn? I know some C, C++, VB.NET, and web programming languages right now.

Man, I can't wait for Spring Break (next week) so I can start playing with the SDK!



Posted by: dingobiatch

Okay the part that's really killing me, even after reading the become an xcoder tutorial you mentioned, is functions. Or is it methods? I'm confused on what's called what.

The thing I do get is the whole messages thing.. implementation functions/methods that look like:
(int)setTo3:num{
[bla dothisaram]
}

I mean what's the whole bracket thing about?? And the colons??



Posted by: jozero

objective C is a 'pure' extension on C, so all the 'weird' parts just let the compiler know what is objective C and what is straight C. (ex. '@' lets the compiler know its an NSString, not a c char array)

Brackets :
so (every major language ) :
shapeMake.square ("hello", 10, 20);

we have a method called square, it requires a name for the square, its height and width.

Objective c uses [ methodName parametername : parameter]
So an objective C fan would say the objC way is more descriptive. For example in square ("hello", 10, 20) which is the height and which is the width ? (obviously less of a concern with code hinting in a good IDE).

[ [shapeMake square] name : @"hello" height : 10 width : 20 ];

(just an example)

All the NS stuff isn't objective C, its the Cocoa frameworks. 'NS' refers to NextStep, where the framework (remember the NeXT computer ?) was originally made. Apple bought Steve Jobs company called NeXT when he returned to Apple. NextStep then became Mac OS X. The 'NS' naming convention is a leftover of that.

I am not a fan of it either, however after a while the 'purity' of the language sets in and you start to see the magic of it. Personally though I agree with the microsoft C# tactic. It saw where the world was going (java, php 5, actionscript OO, etc), essentially ripped off the language with C# and instantly got a zillion more developers.
Apple development would take a HUGE step forward for mass appeal if it just took the ECMA language standard and make a language based around that. Heck they could call it applescript 3.

If you want to do iPhone development just skip anything ObjC 1.0 related and jump into 2.0. It has some 'nice' features that let you use dot syntax (foo.whatever), etc. Unfortunately one thing you will have to sit down and figure out is the garbage collection since iPhone doesn't have this feature of objC 2.0. I would recommend not reading the Apple docs here, Apple docs tend to be very verbose with hardly any examples. Find a quick tutorial. It will basically explain where to use autorelease, and essentially how to count the retains versus the releases. I am no expert at this either.



Posted by: dingobiatch

What is objC 1.0 and what is objC 2.0? (Differences, other than garbage collection.. any pages online I could check out?)

Also, that clears up a lot about methods in objC... but why are there also functions?
I'm going through BecomeAnXCoder guide, and it first introduces functions (equiv. of java methods), and then it brings up methods. It at first speaks as if methods (the bracket ones) are only for messages, which is GUI related.. but then when I go through example iPhone code, it is not like that at all.

Please release java for iPhone, please. Please.



Posted by: jozero

Actually disregard what I said about skipping learning obj 1. You will have a hard time finding an all encompassing obj 2 tutorial. There is a another thread on the SDK forums that points to resources. If you are getting confused by apple documentation skip it initially. The best overall resource is Learn Cocoa Programming by Aaron Hillegass, a new version is coming out coming in Summer covering objective C 2 but the current book is a fantastic guide.

___
Also, that clears up a lot about methods in objC... but why are there also functions? I'm going through BecomeAnXCoder guide
___

Remember ObjC is just an extension on C, so all the C stuff remains. ObjC syntax then tells the compiler when to use its special abilities.

I am generalizing here, but that guide uses functions for C, uh, functions. When it makes Objective C calls, for example if the method is called by an objective C framework, or it returns an objective C type (NSInteger, instead of int,etc) it uses Objective C methods. Its two sides of the same coin. A method for example can take advantage of ObjC dynamic typing, reflection, namespacing, etc which functions generally can't.


____
What is objC 1.0 and what is objC 2.0?
____

ObjC adds some nice features to Objc 1.
Read the article here on what is new :
http://theocacao.com/document.page/510
That site is good. As is this :
http://cocoadevcentral.com/

However we don't get the garbage collection in objective C 2 for iPhone.

Another rant. Objc2 introduces some new property access techniques taking advantage of Key-Value techniques. If you are just learning Objective C this can be confusing as heck. Just remember that in objective C 2 you can access properties in 2 different ways. [whatever setName:@"bob"] works (assuming you have a setter method called setName for property name), and whatever.name = @"bob" works (using KV, it auto generates the getter / setter methods so you are not breaking encapsulation, and not accessing the variable directly). I have no clue why they allowed a different syntax. Garbage collection can also be mixed wiley-nilley.
If property values seem to be coming out of the blue, read up on bindings and KVO, KVC, KVB. This is true magic, how a property on the View gui end can be automatically synced, saved, with undo/redo on the Model side magically. Its nice, but coming from a different language it seems bizarre.



Posted by: KDarling

jozero, many thanks for your insights!



Posted by: rennyn

Quote:
Originally Posted by dizzyj
ya, been reading the objective c stuff. I come from a c++ world and its similar, but the syntax is all funky.

apple did good tho, I've got me a shiney new macbook pro to code on as of today


Hehe exactly what they wanted in all of this I think





vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
vB Easy Archive Final ©2000 - 2008 - Created by Stefan "Xenon" Kaeser