Your SlideShare is downloading. ×
Introduction to Objective c
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Introduction to Objective c

1,820
views

Published on

This Presentation gives a brief introduction to Objective C language. It is intended for audience already familiar to programming concepts and intends to familiarize audience with the syntax of the …

This Presentation gives a brief introduction to Objective C language. It is intended for audience already familiar to programming concepts and intends to familiarize audience with the syntax of the language.

Published in: Education, Technology

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,820
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. OBJECTIVE – CRohit Sharma
  • 2. Objective-C Initially written as a preprocessor for C to add some capabilities of Smalltalk Objective-C is thin layer on top of C Syntax:  For non-object-oriented operations: identical to C  For object-oriented features: similar to Smalltalk
  • 3. Data Types Primitive types similar to that of C Type Definition id Pointer to data structure of object SEL A null-terminated string representing method’s name IMP A pointer to a method implementation BOOL A Boolean value, either YES or NO
  • 4. Classes Objective-C class definitions are seprated into an interface and an implementation part Usually defined in separate .h and .m files
  • 5. Defining the class interface @interface BankAccount : NSObject { float accountBalance; NSString *accountNumber; } -(float)withDraw: (float)amount; -(void)deposit: (float)amount; @end
  • 6. Defining the class interface @interface BankAccount : NSObject { float accountBalance; NSString *accountNumber; } -(float)withDraw: (float)amount; -(void)deposit: (float)amount; @end
  • 7. Defining the class interface @interface BankAccount : NSObject { float accountBalance; NSString *accountNumber; } -(float)withDraw: (float)amount; -(void)deposit: (float)amount; @end
  • 8. Defining the class interface @interface BankAccount : NSObject { float accountBalance; NSString *accountNumber; } -(float)withDraw: (float)amount; -(void)deposit: (float)amount; @end
  • 9. Defining the classimplementation#import “BankAccount.h”@implementation BankAccount- (float)withDraw: (float)amount { // calculations return amount;}-(void)deposit: (float)amount{ //record transaction}@end
  • 10. Defining the classimplementation#import “BankAccount.h”@implementation BankAccount- (float)withDraw: (float)amount { // calculations return amount;}-(void)deposit: (float)amount{ //record transaction}@end
  • 11. Methods & Messages Methods are always public by default. Methods are invoked by passing messages…. Simple messages: [object message]; Messages with arguments:  A method name can be split into several segments [object messageWithArg1:arg1 AndArg2:arg2];
  • 12. Creating Objects Java:  BankAccount account = new BankAccount(); Objective-C:  BankAccount *account = [[BankAccount alloc] init];
  • 13. Properties - Decleration Shorthand for accessors / setters-getters@interface Test0 : NSObject { int iVar;}@property (readwrite) int iVar;@end @property Declares the accessors
  • 14. Properties - Implementation@implementation Test0@synthesize iVar; //code@end @synthesize : implements the accessor methods  set<PropertyName>  <propertyName>
  • 15. COCOAAN INTRODUCTION
  • 16. Introduction Set of object-oriented APIs Composed of two object-oriented frameworks:  Foundation framework:  Provide basic functionalities not impacting UI  Application Kit:  Built on Foundation classes  Provides for handling UI events
  • 17. MVC Architecture M-V-C : Model – View – Controller Isolates LOGIC from USER INTERFACE
  • 18. GUI in Cocoa Nib / Xib Files  An archive of objects serialized to disk  Not generated code  Can contain Application windows and other UI objects Outlets:  Special instance variables containing reference to other objects.  An object can communicate with other objects sending messages to them through outlets
  • 19. GUI in Cocoa Actions  Actions are special methods which are triggered by user-interface objects  Indicated with IBAction keyword
  • 20. DemoA Currency Converter
  • 21. Steps Create the interface Define the Classes Connect Model , Controller and View Implement the Classes Build and Run

×