Showing posts with label Objective C Tutorial. Show all posts
Showing posts with label Objective C Tutorial. Show all posts

Saturday, 1 November 2014

Objective C Code Building Blocks

Hello Friends,

Today I am going to show you how the Objective C programs can be written in a single file.

Before we study Advance building blocks of the Objective-C programming language, let us look a the minimum Objective-C program structure means We are going to create a full Objective Orientated Example with in a single file.

Basic Parts of the Objective C Programming Language:

  • Preprocessor Commands
  • Interface
  • Implementation
  • Method
  • Variables
  • Statements & Expressions
  • Comments


Create you Command Line Project under the Foundation and you will get the main.m file to code. Copy this following code into file.

#import <Foundation/Foundation.h>

/* First Section of .h file (Header ) */
------------------------------------------------------------------------------
@interface FirstClass:NSObject
- (void)showMethod;
@end
-----------------------------------------------------------------------------

/* Second Section of .m file (Implementation) */
@implementation FirstClass

- (void)showMethod{
   NSLog(@"This is the single file Example of Objective C! \n");
}

@end
----------------------------------------------------------------------------

/* Main method which starts the execution */
int main()
{
   /* Create an Instance of the FirstClass to access its method */
   FirstClass *firstClass = [[FirstClass alloc]init];

  /* Calling the showMethod using Class Instance */
   [firstClass showMethod];
   return 0;
}

Let's understand the above code structure


1. The first line of the program "#import <Foundation/Foundation.h>" is a preprocessor command, which tells a Objective-C compiler to include Foundation.h file before going to actual compilation. just like the stdio.h in C Programming language it's a basic library for Objective C language compilation.

2. The next line "@interface FirstClass:NSObject" shows how to create an interface. It inherits NSObject builtIn Class, which is the base class of all objects.

3. The next line "- (void)showMethod;" shows how to declare a method. Here we have to just declare the method and after that we will implement it in other section.

4. The next line "@end" marks the end of an interface.

5. The next line "@implementation FirstClass" shows how to implement the interface FirstClass.

6. The next line "- (void)showMethod{}" shows the implementation of the showMethod.

7. The next line "@end" marks the end of an implementation.

8. The next line "int main()" is the main function where program execution begins just like any other programming language.

9. The next line "/*...*/" will be ignored by the compiler and it has been put to add additional comments in the program. So such lines are called comments in the programs.

10. The next line "NSLog(...)" is another function available in Objective-C which causes the message "This is the single file Example of Objective C!" to be displayed on the screen.

11. The next line "return 0;" terminates main()function and returns the value 0.

I hope you guyes have understood this basic structure of the Objective C programming language. This language is devided into three parts according to the code.

1) Interface File also called the Header file with the extension of .h
2) Implementation file with the extension of .m
3) The main method with the extension of .m file

Video Tutorial




For More Detail you can find the lates information on below url.

http://programming-guru.com/
http://youtube.com/webboostings/
http://webboostings.blogspot.in/


Thank You
Abhishek Bendre

Objective-C Introduction

Hello Friends,

Today I am going to show you How to make iOS App by using Objective C Programming Language.

Introduction

Objective-C is a object-oriented programming language that adds Smalltalk-style messaging to the C programming language. This is the main programming language used by Apple for the OS X and iOS operating systems and their respective APIs, Cocoa and Cocoa Touch till now but now apple has release a new programming lanaguage called SWIFT Programming language but the good news is that both language will support in xCode 6. You can use any language from this two.

This Blog will help you to learn the Objective C language.

Before starting I am hoping that you knows the fundamentals about the computer programs and what is computer programming language?

Compile/Execute Objective-C Programs

In this tutorial all the examples are tested you just need to copy this code and paste it into the xCode and just hit the run button you will see the output.

#import <Foundation/Foundation.h>

int main()
{
   /* First Programming using Objective C */
   NSLog(@"Welcome to the World of iOS Application! \n");
 
   return 0;
}

Video Tutorial




Thank You
Abhishek


For More Details You can visit
http://programming-guru.com/
http://youtube.com/webboostings/
http://webboostings.blogspot.in/