Full Stack Web Development Internship Program
- 29k Enrolled Learners
- Weekend/Weekday
- Live Class
Objective-C is a language that was developed on top of normal C language. It is a general-purpose language. It has the additional features of Small Talk programming language that makes it an object-oriented programming language. In this article we will be exploring what is Objective-C in detail.
Following Pointers will be covered in this article,
So let us get started then,
The Objective-C languages completely support the object-oriented approach. It supports all features of the object-oriented approach like,
Example Code
#import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSLog (@"hello world"); [pool drain]; return 0; }
Output
Explanation
We import the foundation header files which hold the basic functions. With Xcode 5, we can import the Foundation framework as,
@import Foundation;
The main function with an integer return type is declared. The Auto release pool is created to manage the memory in the program. Finally, the Nlog function is used to print statements in Objective-C. “Hello world” is printed here.
Files are stored with .m extension.
Moving on with this What is Objective-C article,
Foundation Framework
Foundation Framework provides many features. Some of these features are listed here,
Moving on with this What is Objective-C article,
Features Of Objective-C
Moving on with this What is Objective-C article,
Structure Of Objective-C
The Objective-C Program is divided into seven parts,
Example Code
#import Foundation.h;//pre-processor commands @interface SampleClass:NSObject//interface (void)sampleMethod; @end @implementation SampleClass//implementation -(void)sampleMethod {//methods NSLog(@"Hello, World! n"); } @end int main() {//main method /* my first program in Objective-C *///commands SampleClass *sampleClass = [[SampleClass alloc]init];//statement and expression [sampleClass sampleMethod]; return 0; }
Output:
Explanation
The Objective C code is divided into seven layers. First, we have the preprocessor commands which are declaring the header files. Then we have an interface that is declared. This is how the creation of an interface is done. @end marks the end of an interface.
This brings us to the end of this article on what is objective-c? I hope you found this informative and helpful, stay tuned for more tutorials on similar topics.You may also checkout our training program to get in-depth knowledge on jQuery along with its various applications, you can enroll here for live online training with 24/7 support and lifetime access.Implement the above code with different strings and modifications. Now, we have a good understanding of all key concepts related to the pointer.
Got a question for us? Mention them in the comments section of this blog and we will get back to you.