tags:

views:

55

answers:

2

I have just started to learn Objective - C. I have done one year of Java programming and one year of Actionscript. I need to find a website or blog which tells me how to do the basic things for example declare a variable or how to write a method and function. I cant seem to find this anywhere. If someone could give me some good links that would be great. Thanks

+8  A: 

Introduction to The Objective-C 2.0 Programming Language from Apple would probably be a good place to get started with the Objective-C language.

In general, declaring variables aren't too different within a method.

-(void)doSomething {
  // Declaration of a variable.
  int myVariable = 0;
}

The syntax for methods and functions can be a little bit different, and the language itself allows the use of C, as Objective-C is a superset of C.

One conceptual difference about classes and objects in Objective-C compared to Java is that the implementation and the declaration is separated into two different files. The "header" information which defines the interface is usually included in the .h file, while the implementation is included in the .m file.

The interface defines the methods, properties and such, while the implementation includes the actual code to use in the methods.

Also, strictly speaking, in Objective-C are not "methods" are not "called", but "messages" are "sent" to objects, and the objects react to them:

// The following is sending the "doSomething" message to "myObject".
// Strictly speaking, it's not a method call, but a messaging of an object.
[myObject doSomething];

Also, the Wikipedia article on Objective-C also gives a pretty good overview of the language as well.

coobird
Thank you i will give it ago
Thats really helpful thank you again.
Glad I could help :)
coobird
+1  A: 

I would highly recommend the book Programming in Objective-C 2.0 by Stephen Kochan.

I used the older version when I was learning Objective-C and still reference it on occasion. It is an excellent introduction to the basics of the language.

Lawrence Johnston
Totally agree. This is one of the most well-written technical books I've ever read. It also does not assume you know C, which many Objective-C books do. It will teach you all you need to know about Objective-C, as well as the bits of plain C you need to know and none of the bits you don't.
Rob Keniger