History
Steve jobs started NextStep to create Good UI on unix OS with Objective c language.
When apple acquired Nextstep renamed to Cocoa and brought same on Macintosh.
Objective C is superset of C.
Objective C is some extra feature addition on top of C.
Apple has provided XCode as IDE for objective c.
1.Hello world Program
Steve jobs started NextStep to create Good UI on unix OS with Objective c language.
When apple acquired Nextstep renamed to Cocoa and brought same on Macintosh.
Objective C is superset of C.
Objective C is some extra feature addition on top of C.
Apple has provided XCode as IDE for objective c.
1.Hello world Program
#import <Foundation/Foundation.h>
int main (int argc, const char *argv[])
{
NSLog (@"Hello, Objective- C!");
return (0);
}
In Xcode following are the extension with language code it contains
.m contain objective C code( The .m extension originally stood for “messages” when Objective- C was first introduced)
.c contain c code
.cpp contain cpp code
there is gcc compiler handles all these 3 languages.
Here we understand the hello world:-
#import :- It is same like #include only difference is #import includes header file only once does not matter how many time u used in one file. (Not require to use #pragma once or header guard in header file). This feature is added in gcc
Foundation.h header file in the Foundation framework.
The Foundation framework handles features found in the layers below the user interface,
such as data structures and communication mechanisms.
Note:- Xcode uses all precompiled header file of framework to avoid time of build process.
main() is same as c .
NSLog() is COCOA function same like printf(). To print things on console.
Difference in NSLog() and printf() is NSLog adds "\n" automatically. and NSLog() can be used to print object with %@.
All function with starting "NS" came from COCOA framework. NS is taken from NextSTEP.
When u add @ sign before string then that string will be treated as NSString which is from cocoa.
(in short NSString is class in used to manipulate and work with strings).
Some tips for Xcode:-
As Objective c is runtime language(every call to function decide at run time depend upon its object type.) so max compile time error will shown as warning . There is setting in Xcode u can make treat Warnings as error.
0 comments:
Post a Comment