Objective C guide for old programmer

A little bit about myself. I used to program 25 years ago using structured languages including assembler, ada, C. I recently changed careers and got into game design. I came out with 2 products I designed myself for Fury Software using their implementation of scripts. So now I am stepping up and we are pushing forward with iOS games for the company and myself. I am a windows person and have got my mac-mini to learn Objective C. My head is going to explode.


I have been at this for 3 weeks with Big Nerd Ranch books, Lynda.com, and other resources I am using. But I simply can't grasp my head around the syntax and format objective C is written in. Really I don't know why anyone would want to write code this way?! Seems a lot more work than its worth.


I actually looked at C++, a language I never learned, and I could understand its syntax far better and I could probably code in it right now with little help.


object.action ( parameter, parameter ) makes sense to me.


[object action:parameter action:parameter]

gives me a headache to look at


especially when it looks like this

[object [object action;parameter]:parameter action:parameter]


I am looking for a resource that will let me learn this in a different way.


Very frustrated person. If I'm in the wrong forum please redirect. Also I can't sign up as a developer for 3 weeks now? Says its down?!?!


I am almost at the point I want to get a cross-platorm software and code in C++.

Objective C-OTHER

Posted on Aug 5, 2013 1:42 PM

Reply
12 replies

Aug 5, 2013 1:58 PM in response to Fuzzypup

It is better to think of it in terms of "receiver" and "message". That is the way Apple refers to it. In your example above, you would say:

[receiver message: param1 more: param2];


So your receiver is "receiver" and your message is actually "message:more:".


Your other example in not correct. It could look like this:

[receiver message: [receiver2 message2] more: param];


Other than that, there isn't much more I can do for you. Objective-C was invented while Lisp was all the rage so it does start to loop a bit Lisp-ish.


I honestly don't know why people get to tied up over a couple of brackets. Have you looked at C++ lately? And you really, really think this is more understandable?

[&] (const string& addr) { return addr.find( name ) != string::npos; }

Aug 5, 2013 2:12 PM in response to etresoft

[&] (const string& addr) { return addr.find( name ) != string::npos; }


if I am reading this correclty pointer addr return true if the name in the object is not at npos. Im guessing because I dont know C++.


Second consideration is to just write in C and use the NS classes for special coding. I'm not some genius programmer, not even close. The syntax of language is very difficult for me to pick up.

Aug 5, 2013 3:32 PM in response to Fuzzypup

Try Programming in Objective-C by Kochan it's a nice gentle step-by-step intro to Object Oriented programming which is what Objective-C is.


It is based on Smalltalk (not lisp) and while confusing at first has a lot of power which unfortunately doesn't become apparent until you've used it for a while. Just give it time and try not to fight it 😉


good luck

Aug 5, 2013 4:41 PM in response to Fuzzypup

Fuzzypup wrote:


[&] (const string& addr) { return addr.find( name ) != string::npos; }


if I am reading this correclty pointer addr return true if the name in the object is not at npos. Im guessing because I dont know C++.



I don't know modern C++. Apparently that is some sort of lambda expression with variable capture.


Second consideration is to just write in C and use the NS classes for special coding. I'm not some genius programmer, not even close. The syntax of language is very difficult for me to pick up.


Almost everything in Objective-C has a pure C counterpart. You can use that, but you are just punishing yourself for no good reason. You miss out on Objective-C language features like properties and ARC. You're not still manually releasing memory are you?


It's just syntax.

Aug 8, 2013 2:25 PM in response to Fuzzypup

You didn't ask a spcific question so it's not really possible to offer much help. You are allowing your frustration to get in the way of the learning process. OO programming requires a definite change in your approach to programming and it will not come quickly.


If the project you have chosen to start with is causing you this much trouble then the project is to advanced for your current level of understanding. You need to drop back and start more slowly.


Have you gotten the Cochran book? Have you followed his exercises in the order presented?


You might also what to look at Apple's Programming with Objective-C tutorial as well as Start Developing Mac Apps Today


Good luck,


regards

Aug 11, 2013 9:04 PM in response to UKAnon31

So finally I am begining to grasp this thing. I found my problem on how the code is presented


NSUInteger day = [cal ordinalityOfUnit: NSDayCalendarUnit inUnit: NSMonthCalendarUnit forDate: now];

*** My head was going to explode with the spacing.


NSUInteger day = [cal ordinalityOfUnit:NSDayCalendarUnit inUnit:NSMonthCalendarUnit forDate:now];

*** much more readable for me. I'm using my own color coding not italics or bold. I just did it because I can't show it in color on the forum. The spaces between the parameters were killing me. So for anyone else I suggest color coding classes, methods, variables, text, commands so you can quickly ID them when you read objective C if you were having trouble with it.


I still prefer C or C++ over Objective-C.


So I have a question....


I have now spent 10 total hours in front of the PC trying to figure out how to write an NSArray to file.


I have to make an assumption due to the lack of explaination from the countless sources I have gone to on to exactly what is going on. When you read/write an NSArray to a file do you just read/write the whole array without indexing it like in C?

Like in C you would use a for loop if you wanted to write a simple array of intergers to a file using putw and getw.


Can you mix an NSArray of one thing and NSString of another in the same saved file and call it back where it stops at the NULL at the end of each data type?

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Objective C guide for old programmer

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.