Here in this series of objective-c cookbook series, I am gonna arrange all my experiences in learning objective-c and present them in a more readable structure. I hope this will lower down the barrier of learning such an appealing language.
This cookbook is for ones who have programming experiences and already know the basics of programming languages, which means, some basic concepts like variable, basic types and operators will not be mentioned in this cookbook.
This cookbook is for ones who have programming experiences and already know the basics of programming languages, which means, some basic concepts like variable, basic types and operators will not be mentioned in this cookbook.
What's Objective-C(ObjC)?
Well, there's a history behind the objc. But, all you have to know is it's a language based on ANSI C and now is the primary language used in developing MacOSX and iOS applications.
What are required to program in ObjC?
[MacOSX]
All you have to do is to download the XCode via the built in app store. Of course you buy yourself some reference books as well.
[Windows]
To program in ObjC under windows environment, you have to get yourself a compiler. like GCC, to convert your ObjC code into binary executive format. Unfortunately, having a compiler is not enough. In a native ObjC code, there are lots of predefined components a GCC cannot understand. Hence, once you download the GCC, you have to get some predefined libraries such as GNUStep to make the GCC "knows" the content of your ObjC code. Here's the reference to setup ObjC programming environment in windows.
However, it requires too much effort to program in ObjC under windows environment. In the reset of this cookbook, the contents will all based on MacOSX.
The Basic In the Basic
The following code segment is the example of the famous "Hello, World!".
The code segment is a classical example of integrating C and ObjC, which contains the entry point "main" of C, built-in types of C, the memory management schema "autoreleasepool" of ObjC and some predefined system types by ObjC.
Well, I guess that I'll leave this code segment to you to study.
You may want to check some concepts by yourself. And the keywords related to this code segment are list as follows.
[Autorelease Pool], [Cocoa Objects], [Foundation Framework], [ObjC Programming].
In my next post, I'll have this code segment fully explained and give you some appropriate resources like how to run this code using XCode, some related official manuals.
What are required to program in ObjC?
[MacOSX]
All you have to do is to download the XCode via the built in app store. Of course you buy yourself some reference books as well.
To program in ObjC under windows environment, you have to get yourself a compiler. like GCC, to convert your ObjC code into binary executive format. Unfortunately, having a compiler is not enough. In a native ObjC code, there are lots of predefined components a GCC cannot understand. Hence, once you download the GCC, you have to get some predefined libraries such as GNUStep to make the GCC "knows" the content of your ObjC code. Here's the reference to setup ObjC programming environment in windows.
However, it requires too much effort to program in ObjC under windows environment. In the reset of this cookbook, the contents will all based on MacOSX.
The Basic In the Basic
The following code segment is the example of the famous "Hello, World!".
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool
{
NSString* string = @"Hello, World! This is ObjC Code Segment!";
NSLog(@"%@", string);
}
return 0;
}
The code segment is a classical example of integrating C and ObjC, which contains the entry point "main" of C, built-in types of C, the memory management schema "autoreleasepool" of ObjC and some predefined system types by ObjC.
Well, I guess that I'll leave this code segment to you to study.
You may want to check some concepts by yourself. And the keywords related to this code segment are list as follows.
[Autorelease Pool], [Cocoa Objects], [Foundation Framework], [ObjC Programming].
In my next post, I'll have this code segment fully explained and give you some appropriate resources like how to run this code using XCode, some related official manuals.

No comments:
Post a Comment