Showing posts with label iOS. Show all posts
Showing posts with label iOS. Show all posts
Tuesday, 18 March 2014
Tuesday, 9 April 2013
iOS Calculator - Just Add
Calculator.h
---------------
#import <Foundation/Foundation.h>
@interface Calculator : NSObject
-(int) add:(int)a and:(int)b;
@property (retain) NSString *name;
@end
Calculator.m
----------------
#import "Calculator.h"
@implementation Calculator
-(int) add:(int)a and:(int)b
{
return a + b;
}
@synthesize name;
@end
main.m
---------
#import
#import "Calculator.h"
int main(int argc, const char * argv[])
{
@autoreleasepool {
// insert code here...
NSLog(@"Hello, World!");
Calculator *calculator = [[Calculator alloc] init];
int sum = [calculator add:10 and:20];
NSLog(@"%d", sum);
calculator.name = @"Simple Calculator";
NSLog(@"%@", calculator.name);
[calculator release];
}
return 0;
}
---------------
#import <Foundation/Foundation.h>
@interface Calculator : NSObject
-(int) add:(int)a and:(int)b;
@property (retain) NSString *name;
@end
Calculator.m
----------------
#import "Calculator.h"
@implementation Calculator
-(int) add:(int)a and:(int)b
{
return a + b;
}
@synthesize name;
@end
main.m
---------
#import
#import "Calculator.h"
int main(int argc, const char * argv[])
{
@autoreleasepool {
// insert code here...
NSLog(@"Hello, World!");
Calculator *calculator = [[Calculator alloc] init];
int sum = [calculator add:10 and:20];
NSLog(@"%d", sum);
calculator.name = @"Simple Calculator";
NSLog(@"%@", calculator.name);
[calculator release];
}
return 0;
}
Labels:
iOS,
Objective-C,
XCode
Location:
Bangalore, Karnataka, India
First iOS Application - Hello World
Started XCode, selected TabView application, and modified FirstView.xib to get my first iOS application up in Simulator.
Location:
Bangalore, Karnataka, India
Subscribe to:
Posts (Atom)

