SlideShare una empresa de Scribd logo
1 de 64
Tutorial - 1
Mobile application development platforms,
Android, Windows, iOS, Bada, Blackberry etc.
Android, iOS, and Windows application
development is high on demand and will remain
for coming few years.
Android/iOS and Windows application
development is also possible using non standard
tools.
Android: eclipse + android sdk or Android
Studio or Epselorator Studio (HTML5 + CSS3)
or Phone Gap or TheAppBuilder.com etc.
iOS: Xcode + MAC, Adobe, Appselorator
Studio (HTML5 + CSS3) or Phone Gap or The
App Builder etc.
Blackberry: Eclipse + Blackberry SDK
Windows: .NET
Tutorial – 2
#import <Foundation/Foundation.h>
int main (int argc, const char *argv[])
{
@NSAutoreleasepool
{
NSLog(@"Hello world");
[pool drain];
return 0;
}
}
Tutorial – 3
#import <Foundation/Foundation.h>
int main (int argc, const char *argv[])
{
@NSAutoreleasepool
{
int n1=20;
int n2=40;
int sum=n1+n2;
NSLog(@"The sum of %i and %i
is %i",n1,n2,sum);
[pool drain];
return 0;
}
}
Tutorial – 4
@interface Person:NSObject
{
int age;
int weight;
}
-(void) print;
-(void) setAge : (int) a;
-(void) setWeight : (int) w;
@end
@implementation Person
-(void) print
{
NSLog (@"I am %i years old and weigh %i
pounds", age,weight);
}
-(void) setAge : (int) a
{
age=a;
}
-(void) setWeight : (int) w
{
weight=w;
}
@end
int main (int argc, const char argv[])
{
@NSAutoreleasepool
{
Person *ankit;
ankit=[Person alloc];
ankit=[Person init];
[ankit setAge:20];
[ankit setWeight:100];
[ankit print];
return 0;
}
}
Replacement in previous tutorial
Tutorial: 5
Person *name= [[Person alloc]init];
Person *sandy=[[Person alloc]init];
[sandy setAge: 21];
[sandy setWeight:450];
[sandy print];
[sandy release];
[pool drain];
return 0;
Tutorial – 6
Encapsulation
@interface Person:NSObject
{
int age,
int weight,
}
-(void) print;
-(void) setAge : (int) a;
-(void) setWeight : (int) w;
-(int) age;
-(int) weight;
@end
@implementation Person
-(void) print
{
NSLog (@"I am %i years old and weigh %i
pounds", age,weight);
}
-(int) setAge : (int) a
{
age=a;
}
-(int) setWeight : (int) w
{
weight=w;
}
-(int) age
{
return age;
}
-(int) weight
{
return weight;
}
@end
int main(int argc, const char * argv[])
{
@NSAutoreleaspool
{
Person *name= [[Person alloc]init];
[name setAge:25];
[name setWeight: 200];
NSLog(@"Name is %i and weighs %i",
[name age],[name
weight]);
[name release];
[pool drain];
return 0;
}
}
Tutorial – 7
Data Types
#import <Foundation/Foundation.h>
int main (int argc, const char *argv[])
{
@NSAutoreleasepool
{
int i=20;
float f=31.37;
double d= 9/32;
char c = ‘a’;
NSLog (@"%i",i);
NSLog (@"%f",f);
NSLog (@"%e",d);
NSLog (@"%c",c);
[pool drain];
return 0;
}
}
Tutorial – 8
TypeCasting
#import <Foundation/Foundation.h>
int main (int argc, const char *argv[])
{
@NSAutoreleasepool
{
int i1, i2=15, i3=10;
float f1=20.86, f2;
i1=f1;
NSLog (@"%i",i1);
f2=i2/i3;
NSLog (@"%f",f2);
f2=f1/i3;
NSLog (@"%f",f2);
[pool drain];
return 0;
}
}
Tutorial – 9
Type Casting (Explicite)
#import <Foundation/Foundation.h>
int main (int argc, const char *argv[])
{
@NSAutoreleasepool
{
int i1, i2=15, i3=10;
float f1=20.86, f2;
f2=(float)i3/8;
NSLog (@"%f",f2);
int name = (int)22.77;
NSLog (@"%i",name);
name = name + 5; // name += 5;
NSLog(@"%i", name);
(Shorthand)
name+=5;
NSLog(@"%i", name);
[pool drain];
return 0;
}
}
LOOPS
Tutorial – 10
For Loop:-
#import <Foundation/Foundation.h>
int main (int argc, const char *argv[])
{
@NSAutoreleasepool
{
for(int i=1;i<=10;i++)
NSLog(@"%i", i);
[pool drain];
return 0;
}
}
Tutorial – 11
#import <Foundation/Foundation.h>
int main (int argc, const char *argv[])
{
@NSAutoreleasepool
{
int i, usernumber;
NSLog (@"Enter the number and I will print
it");
scanf("%i",& usernumber);
for(int i=1; i<= usernumber ; i++)
NSLog(@"%i",i);
[pool drain];
return 0;
}
}
Tutorial – 12
Nested For Loop:-
#import <Foundation/Foundation.h>
int main (int argc, const char *argv[])
{
@NSAutoreleasepool
{
int usernumber;
for(int a=1; a<=3;a++)
{
NSLog(@"Enter a number");
scanf(“%i",&usernumber);
for(int b=1; b<= usernumber; b++)
NSLog(@"%i",usernumber);
}
[pool drain];
return 0;
}
}
Tutorial – 13
While Loop:-
#import <Foundation/Foundation.h>
int main (int argc, const char *argv[])
{
@NSAutoreleasepool
{
int num=1 ;
while (num<=6)
{
NSLog(@"%i",num);
num++;
}
[pool drain];
return 0;
}
}
Tutorial – 14
#import <Foundation/Foundation.h>
int main (int argc, const char *argv[])
{
@NSAutoreleasepool
{
int num=1 ;
int name;
scanf(“%i",&name);
while (num<=10)
{
NSLog(@"%i time %i= %i", num, name,
num*name);
num++;
}
[pool drain];
return 0;
}
}
Tutorial – 15
Do-While Loop:-
#import <Foundation/Foundation.h>
int main (int argc, const char *argv[])
{
@NSAutoreleasepool
{
int n=1 ;
do
{
NSLog(@"%i",n);
n++;
}
while (n<=5);
[pool drain];
return 0;
}
}
Tutorial – 16
#import <Foundation/Foundation.h>
int main (int argc, const char *argv[])
{
@NSAutoreleasepool
{
int n=1 ;
do
{
NSLog(@"%i squared is %i",n,n*n);
n++;
}
while (n<=10);
[pool drain];
return 0;
}
}
Tutorial – 17
#import <Foundation/Foundation.h>
int main (int argc, const char *argv[])
{
@NSAutoreleasepool
{
int n,r ;
NSLog(@"Enter a number");
scanf(“%i",&n);
r=n%2;
if(r==0)
NSLog(@"Your number is even");
else
NSLog(@"Your number is odd");
[pool drain];
return 0;
}
}
Tutorial – 18
Relational test and nested if
#import <Foundation/Foundation.h>
int main (int argc, const char *argv[])
{
@NSAutoreleasepool
{
int age,sex;
NSLog(@"Enter age");
scanf(“%i",&age);
NSLog(@"Enter sex (1:Boy 2:Girl)");
scanf(“%i",&sex);
if (age<18 || age >80)
NSLog(@"Go to another website");
else
{
if(sex==1)
NSLog(@"Welcome Man!!");
else
NSLog(@"Welcome Girl!!");
}
[pool drain];
return 0;
}
}
Tutorial – 19
Else if ladder
#import <Foundation/Foundation.h>
int main (int argc, const char *argv[])
{
@NSAutoreleasepool
{
int time;
NSLog(@"Enter the time");
scanf(“%i",&time);
if(time<11)
NSLog(@"Gud Morning!!");
else if(time<16)
NSLog(@"Gud Afternoon!!");
else if(time<24)
NSLog(@"Gud Night!!");
else
NSLog(@"What did u enter????");
[pool drain];
return 0;
}
}
Tutorial – 20
Switch
#import <Foundation/Foundation.h>
int main (int argc, const char *argv[])
{
@NSAutoreleasepool
{
int age=2;
switch(age)
{
case 1:
NSLog(@"They are cute");
break;
case 2:
NSLog(@"They are terrible");
break;
case 3:
NSLog(@"They are thirsty");
break;
case 4:
NSLog(@"They are 4");
break;
default:
NSLog(@"Enter valid number");
}
}
[pool drain];
return 0;
}
Tutorial – 21
Conditional Operator
#import <Foundation/Foundation.h>
int main (int argc, const char *argv[])
{
@NSAutoreleasepool
{
int a=2,b=3,c=0;
a==b ? NSLog(@"They are equal") :
NSLog(@"They are different");
c ? NSLog(@"True") : NSLog
(@"False");
}
[pool drain];
return 0;
}
Tutorial – 22
MVC Architecture
Person.h
@interface Person:NSObject
{
int age,weight;
}
-(void) print;
-(void) setAge : (int) a;
-(void) setWeight : (int) w;//void setWeight(int
w);
@end
Person.m
#import “Person.h"
@implementation Person
-(void) print
{
NSLog (@"I am %i years old and weigh %i
pounds", age,weight);
}
-(void) setAge : (int) a
{
age=a;
}
-(void) setWeight : (int) w
{
weight=w;
}
@end
Main.m
#import<Foundation/Foundation.h>
#import “Person.h"
int main (int argc, const char argv[])
{
@NSAutoreleasepool
{
Person *name=[[Person alloc]init];
//Person ob = new Person();
[name setAge:20];
[name setWeight:100];
[name print];
[name release];
[pool drain];
return 0;
}
}
Tutorial – 23
Automatic Setter& Getter
Person.h
@interface Person:NSObject
{
int age,weight;
}
@property int age,weight;
-(void) print;
@end
Person.m
#import "Person.h"
@implementation Person
@synthesis age,weight;
-(void) print
{
NSLog(@"I am %iyears old and weigh %i
pounds", age, weight);
}
@end
Main.m
#import<Foundation/Foundation.h>
#import “Person.h"
int main (int argc, const char argv[])
{
@NSAutoreleasepool
{
Person *name=[[Person alloc]init];
name.age = 20;
name.weight = 100;
[name print];
[name release];
[pool drain];
return 0;
}
}
Tutorial – 24
Multiple Arguments
Person.h
@interface Person:NSObject
{
int age,weight;
}
@property int age,weight;
@end
-(void) print;
-(void) dateAge : (int) a : (int) i;
Person.m
#import"Person.h"
-(void) print
{
NSLog(@"I am %iyears old and weigh %i
pounds", age, weight);
}
-(void) dateAge : (int) a : (int) i
{
NSLog(@"You can date %i years old", (a/2+7)-
(i/10000));
}
Main.m
#import <Foundation/Foundation.h>
#import "Person.h"
int main (int argc, const char argv[])
{
@NSAutoreleasepool
{
Person *name=[[Person alloc]init];
name.age = 12;
name.weight = 120;
[name print];
[name dateAge : 30:300000];
[name release];
[pool drain];
return 0;
}
}
Tutorial – 25
Inheritance
Main.m
#import <Foundation/Foundation.h>
@interface Lesley: NSObject
{
int a;
}
-(void) meth;
@end
@implementation Lesley
-(void) meth
{
a=50;
}
@end
@interface Son: Lesley
-(void) printThing;
@end
@implementation Son
-(void) printThing
{
NSLog(@"%i",a);
}
@end
int main (int argc, const char argv[])
{
@NSAotoreleasepool
{
son *s=[[son alloc]init];
[s meth];
[s printThing];
[s release];
[pool drain];
return 0;
}
}
Tutorial – 26
Rectangle.h
@interface Rectangle:NSObject
{
int width, height;
}
@property int width,height;
-(int) area;
-(int) parameter;
-(void) setWH : (int) w : (int) h;
@end
Rectangle.m
#import “Rectangle.h"
@implementation Rectangle
@synthesize width,height;
-(void) setWH : (int)w : (int)h
{
width=w;
height=h;
}
-(int) area
{
return width*height;
}
-(int) parameter
{
return (width+height)*2;
}
@end
Main.m
#import <Foundation/Foundation.h>
#import "Rectangle.h"
int main (int argc, const char argv[])
{
@NSAutoreleasepool
{
Rectangle *r=[[Rectangle alloc]init];
[r setWH:6:8];
NSLog(@"Rectangle is %i
by %i",r.width,r.height);
NSLog(@"Area is %i, Parameter is %i",[r
area],[r parameter]);
[r release];
return 0;
}
}
Tutorial – 27
Square.h
#import “Rectangle.h"
@interface Square:Rectangle
-(void) setSide: (int)s;
-(int) side;
@end
Square.m
#import “square.h"
@implementation Square: Rectangle
-(void) setSide : (int)s
{
[self setWH :s:s];
}
-(int) side
{
return width;
}
@end
Main.m
#import <Foundation/Foundation.h>
#import “Square.h"
int main (int argc, const char argv[])
{
@NSAutoreleasepool
{
Square *s= [[Square alloc]init];
[s setSide:6];
NSLog(@"One side is %i", [s side]);
NSLog(@"Area is %i and perameter
is %i",[s area],[s parameter]);
[s release];
[pool drain];
return 0;
}
}
Tutorial – 28
Mom.h
@interface Mom:NSObject
{
int num1;
}
-(void) setNum1;
@end
Mom.m
#import “Mom.h"
@implementation Mom
-(void) setNum1
{
num1=70;
}
@end
Son.h
#import “Mom.h"
@interface Son:Mom
-(void) setNum1;
-(void)printNumber;
@end
Son.m
#import “Son.h"
@implementation Son
-(void)setNum1
{
num1= 14;
}
-(void)printNumber
{
NSLog(@"The number is %i",num1);
}
@end
Main.m
#import<Foundation/Foundation.h>
#import “Son.h"
int main (int argc, const char argv[])
{
@NSAutoreleasepool
{
Son *s=[[Son alloc]init];
[s setNum];
[s printNumber];
[s release];
[pool drain];
return 0;
}
}
Tutorial – 29
numz.h
@interface numz:NSObject
{
int num1,num2,ans;
}
-(void) setNumbers : (int) a : (int) b;
-(void) add;
-(void) print;
Numz.m
@implementation Numz
-(void) setNumbers: (int) a: (int) b
{
num1 = a;
num2= b;
}
-(void) add
{
ans=num1+num2;
}
-(void) print
{
NSLog(@"I am from numz class, %i",ans);
}
@end
charz.h
@interface charz:NSObject
{
char c1;
char c2;
}
-(void) setCharz;
-(void)add;
-(void)print;
@end
charz.m
@implementation charz
-(void) setCharz
{
c1=’B’;
c2=’W’;
}
-(void) add
{
NSLog(@"%c %c",c1,c2);
}
-(void)print
{
NSLog(@"I am from the chaz class");
}
Main.m
#import<Foundation/Foundation.h>
#import “numz.h"
#import “charz.h"
int main (int argc, const char argv[])
{
@NSAutoreleasepool
{
numz *n =[[numz alloc]init];
charz *c =[[charz alloc]init];
[n setNumbers :8:10];
[n add];
[n print];
[c setCharz];
[c add];
[c print];
[n release];
[c release];
[pool drain];
return 0;
}
}
Tutorial – 30
numz.h
@interface numz:NSObject
{
int num1,num2,ans;
}
-(void) setNumbers : (int) a : (int) b;
-(void) add;
-(void) print;
Numz.m
@implementation Numz
-(void) setNumbers: (int) a: (int) b
{
num1 = a;
num2= b;
}
-(void) add
{
ans=num1+num2;
}
-(void) print
{
NSLog(@"I am grom numz class, %i",ans);
}
@end
charz.h
@interface charz:NSObject
{
char c1;
char c2;
}
-(void) setCharz;
-(void)add;
-(void)print;
@end
charz.m
@implementation charz
-(void) setCharz
{
c1=’B’;
c2=’W’;
}
-(void) add
{
NSLog(@"%c %c",c1,c2);
}
-(void)print
{
NSLog(@"I am from the chaz class");
}
Main.m
#import<Foundation/Foundation.h>
#import “numz.h"
#import “charz.h"
int main (int argc, const char argv[])
{
@NSAutoreleasepool
{
numz *n =[[numz alloc]init];
charz *c =[[charz alloc]init];
[n setNumbers :8:10];
[n add];
[n print];
[c setCharz];
[c add];
[c print];
[n release];
[c release];
[pool drain];
return 0;
}
}
Tutorial – 31
numz.h
@interface numz:NSObject
{
int num1,num2,ans;
}
-(void) setNumbers : (int) a : (int) b;
-(void) add;
-(void) print;
Numz.m
@implementation Numz
-(void) setNumbers: (int) a: (int) b
{
num1 = a;
num2= b;
}
-(void) add
{
ans=num1+num2;
}
-(void) print
{
NSLog(@"I am grom numz class, %i",ans);
}
@end
charz.h
@interface chaez:NSObject
{
char c1;
char c2;
}
-(void) setCharz;
-(void)add;
-(void)print;
@end
charz.m
@implementation charz
-(void) setCharz
{
c1=’B’;
c2=’W’;
}
-(void) add
{
NSLog(@"%c %c",c1,c2);
}
-(void)print
{
NSLog(@"I am from the chaz class");
}
Main.m
#import<Foundation/Foundation.h>
#import “numz.h"
#import “charz.h"
int main (int argc, const char argv[])
{
@NSAutoreleasepool
{
id tuna;
numz *n =[[numz alloc]init];
charz *c=[[charz alloc]init];
tuna=n;
[tuna print];
tuna=c;
[tuna print];
[pool drain];
return 0;
}
}
Tutorial – 32
Exception Handling
numz.h
@interface numz:NSObject
{
int num1,num2,ans;
}
-(void) setNumbers : (int) a : (int) b;
-(void) add;
-(void) print;
Numz.m
@implementation Numz
-(void) setNumbers: (int) a: (int) b
{
num1 = a;
num2= b;
}
-(void) add
{
ans=num1+num2;
}
-(void) print
{
NSLog(@"I am grom numz class, %i",ans);
}
@end
Main.m
#import<Foundation/Foundation.h>
#import “numz.h"
int main (int argc, const char argv[])
{
@NSAutoreleasepool
{
numz *n =[[numz alloc]init];
@try
{
[n this_is_gonna_get_error];
}
@ catch (NSException *e)
{
NSLog(@"you got an error in your
program");
}
NSLog(@"this is the code after error");
[pool drain];
return 0;
}
}
Tutorial – 33
Extern keyword
tuna.h
@interface tuna:NSObject
-(void) changeVar;
tuna.m
@implementation tuna
-(void) changeVar
{
extern int gdrunk;
gdrunk=13;
}
Main.m
#import<Foundation/Foundation.h>
#import “tuna.h"
int gdrunk=21; //Global Variable
int main (int argc, const char argv[])
{
@NSAutoreleasepool
{
tuna *f =[[tuna alloc]init];
[f changeVar];
NSLog(@"%i",gdrunk);
[f release];
[pool drain];
return 0;
}
}
Tutorial – 34
Enumerated Data Type
main.m
#import<Foundation/Foundation.h>
int main (int argc, const char argv[])
{
@NSAutoreleasepool
{
enum day {m,t,w,th,f};
enum day entry;
NSLog(@"Enter the number for getting the
day");
scanf(“%i",&entry);
switch(entry)
{
case m:
NSLog(@"Monday");
break;
case t:
NSLog(@"Tuesday");
break;
case w:
NSLog(@"Wednesday");
break;
case th:
NSLog(@"Thursday");
break;
case f:
NSLog(@"Friday");
break;
default:
NSLog(@"Enter the number within the
range");
break;
}
}
}
Tutorial – 35
Define Statement
crap.m
#define BACON 23
#define TOAST 44
main.m
#import <Foundation/Foundation.h>
#import “crap.h"
int main(int argc, const char *argv[])
{
@NSAutoreleasepool
{
int x= TOAST + BACON;
NSLog(@"%i",x);
[pool drain];
}
}
Tutorial – 36
Frameworks
NSNumber
main.m
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool
{
NSNumber *buckyint,*buckyfloat;
buckyint=[NSNumber numberWithInteger:100];
buckyfloat=[NSNumber numberWithFloat:100.123];
int x=[buckyint intValue];
float y=[buckyfloat floatValue];
NSLog(@"%i and %f",x,y);
if ([buckyint isEqualToNumber:buckyfloat]==YES)
NSLog(@"They are equal");
else
NSLog(@"They are not equal");
if ([buckyint
compare :buckyfloat]==NSOrderedAscending)
NSLog(@"First number is less");
else
NSLog(@"Second Number is less");
return 0;
}
}
Tutorial – 37
String Objects
main.m
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool
{
NSString *s=@"dont do this";
NSString *tester;
printf("%@",s);
NSLog(@"Length is %i",[s length]);
tester=[NSString stringWithString:s];
NSLog(@"Copied string is %@",tester);
tester=[s uppercaseString];
NSLog(@"%@", tester);
}
return 0;
}
Tutorial – 38
Substring
main.m
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool
{
NSString *s = @"Cats dont like bananas";
NSString *d = @"Don’t feed grapes to dogs";
NSString *tester;
tester = [d substringToIndex:10];
NSLog(@"First 10 characters are %@",tester);
tester = [d substringFromIndex:10];
NSLog(@"From 10 till the end %@",tester);
//tester = [d substringWithRange (5,11)];
//NSLog(@" %@",tester);
NSRange range = [d rangeOfString:@"grapes"];
NSLog(@"Location is %i and length is %i",
range.location,range.length);
}
return 0;
}
Tutorial – 39
Mutable String
main.m
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSString *dog = @"Hot dog ";
NSMutableString *mute;
mute = [NSMutableString stringWithString:dog];
NSLog(@"%@",mute);
[mute insertString: @"sauce" atIndex:8];
NSLog(@"%@",mute);
[mute deleteCharactersInRange:
NSMakeRange(4,3)];
NSLog(@"%@",mute);
}
return 0;
}
Tutorial – 40
Mutable String
main.m
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSString *dog = @"Hot dog? I thought you said
pumpkin";
NSMutableString *mute;
mute = [NSMutableString stringWithString:dog];
NSLog(@"%@",mute);
[mute setString: @"I am a new string!"];
NSLog(@"%@",mute);
[mute replaceCharactersInRange :
NSMakeRange(11,7) withString :@"mother!"];
NSLog(@"%@",mute);
NSString *old=@"mother";
NSString *new=@"baby seal";
NSRange therange = [mute rangeOfString:old];
[mute replaceCharactersInRange:therange
withString:new];
NSLog(@"%@",mute);
}
return 0;
}
Tutorial – 41
Array
main.m
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSArray * food =[NSArray
arrayWithObjects:@"apple",@"orang",@"mango",@"bana
na", nil];
for(int i=0;i<4;i++)
{
NSLog(@"item at index %i is %@",i,[food
objectAtIndex:i]);
}
}
return 0;
}
Tutorial – 42
Mutable Array
main.m
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSMutableArray *changeme = [NSMutableArray
arrayWithCapacity:25];
[changeme addObject: [NSNumber
numberWithInteger:2]];
for(int i=0;i<=100;i++)
{
[changeme addObject:[NSNumber
numberWithInteger:i]];
}
for(int x=0;x<[changeme count];x++)
{
NSLog(@"%d=%li",x,(long)[[changeme
objectAtIndex:x]integerValue]);
}
return 0;
}
}
Tutorial – 43
Dictionaries
main.m
#import <Foundation/Foundation.h>
int main(int argc, const char argv[])
{
@NSAutoreleasepool
{
NSMutableDictionary *mydic =
[NSMutableDictionary dictionary];
[mydic setObject:@"When you spray youself
with free breez" forKey:@"freebreez shower"];
[mydic setObject:@"gamer who lacks
experience" forKey:@"Noob"];
[mydic setObject:@"worst food on the planet"
forKey:@"sushi"];
NSLog(@"%@",[mydic
objectForKey:@"sushi"]);
}
}
Tutorial – 44
Files
main.m
#import <Foundation/Foundation.h>
int main(int argc, const char argv[])
{
@NSAutoreleasepool
{
NSString *testerfile = @"testerfile";
NSFileManager *manager;
manager=[NSFileManager defaultManager];
//Creates a default file manager
if([manager fileExistsAtPath : testerfile]==NO)
{
NSLog(@"File does not exists");
return 1;
}
// Copy of a file
if ([manager copyItemAtPath : testerfile
toPath:@"newfile" error : NULL]== NO)
{
NSLog(@"Cannot copy the file");
return 2;
}
//Rename the copy file
if ([manager moveItemAtPath:@"newfile"
toPath:@"newfile2" error:NULL]==NO)
{
NSLog(@"Cannot rename it");
return 3;
}

Más contenido relacionado

La actualidad más candente

Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8XSolve
 
Un dsl pour ma base de données
Un dsl pour ma base de donnéesUn dsl pour ma base de données
Un dsl pour ma base de donnéesRomain Lecomte
 
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...tdc-globalcode
 
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)James Titcumb
 
Odoo - From v7 to v8: the new api
Odoo - From v7 to v8: the new apiOdoo - From v7 to v8: the new api
Odoo - From v7 to v8: the new apiOdoo
 
Sorting programs
Sorting programsSorting programs
Sorting programsVarun Garg
 
PHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolvePHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolveXSolve
 
bullismo e scuola primaria
bullismo e scuola primariabullismo e scuola primaria
bullismo e scuola primariaimartini
 
Template Haskell とか
Template Haskell とかTemplate Haskell とか
Template Haskell とかHiromi Ishii
 
Aaron Bedra - Effective Software Security Teams
Aaron Bedra - Effective Software Security TeamsAaron Bedra - Effective Software Security Teams
Aaron Bedra - Effective Software Security Teamscentralohioissa
 
Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Seri Moth
 
Invertible-syntax 入門
Invertible-syntax 入門Invertible-syntax 入門
Invertible-syntax 入門Hiromi Ishii
 
Web Optimization Summit: Coding for Performance
Web Optimization Summit: Coding for PerformanceWeb Optimization Summit: Coding for Performance
Web Optimization Summit: Coding for Performancejohndaviddalton
 
Crafting beautiful software
Crafting beautiful softwareCrafting beautiful software
Crafting beautiful softwareJorn Oomen
 
Decoupling with Design Patterns and Symfony2 DIC
Decoupling with Design Patterns and Symfony2 DICDecoupling with Design Patterns and Symfony2 DIC
Decoupling with Design Patterns and Symfony2 DICKonstantin Kudryashov
 
GeeCON Prague 2014 - Metaprogramming with Groovy
GeeCON Prague 2014 - Metaprogramming with GroovyGeeCON Prague 2014 - Metaprogramming with Groovy
GeeCON Prague 2014 - Metaprogramming with GroovyIván López Martín
 
Building fast interpreters in Rust
Building fast interpreters in RustBuilding fast interpreters in Rust
Building fast interpreters in RustIngvar Stepanyan
 

La actualidad más candente (20)

Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8
 
mobl
moblmobl
mobl
 
Un dsl pour ma base de données
Un dsl pour ma base de donnéesUn dsl pour ma base de données
Un dsl pour ma base de données
 
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
 
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
 
Odoo - From v7 to v8: the new api
Odoo - From v7 to v8: the new apiOdoo - From v7 to v8: the new api
Odoo - From v7 to v8: the new api
 
Sorting programs
Sorting programsSorting programs
Sorting programs
 
PHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolvePHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolve
 
bullismo e scuola primaria
bullismo e scuola primariabullismo e scuola primaria
bullismo e scuola primaria
 
Template Haskell とか
Template Haskell とかTemplate Haskell とか
Template Haskell とか
 
F[5]
F[5]F[5]
F[5]
 
Aaron Bedra - Effective Software Security Teams
Aaron Bedra - Effective Software Security TeamsAaron Bedra - Effective Software Security Teams
Aaron Bedra - Effective Software Security Teams
 
Min-Maxing Software Costs
Min-Maxing Software CostsMin-Maxing Software Costs
Min-Maxing Software Costs
 
Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02
 
Invertible-syntax 入門
Invertible-syntax 入門Invertible-syntax 入門
Invertible-syntax 入門
 
Web Optimization Summit: Coding for Performance
Web Optimization Summit: Coding for PerformanceWeb Optimization Summit: Coding for Performance
Web Optimization Summit: Coding for Performance
 
Crafting beautiful software
Crafting beautiful softwareCrafting beautiful software
Crafting beautiful software
 
Decoupling with Design Patterns and Symfony2 DIC
Decoupling with Design Patterns and Symfony2 DICDecoupling with Design Patterns and Symfony2 DIC
Decoupling with Design Patterns and Symfony2 DIC
 
GeeCON Prague 2014 - Metaprogramming with Groovy
GeeCON Prague 2014 - Metaprogramming with GroovyGeeCON Prague 2014 - Metaprogramming with Groovy
GeeCON Prague 2014 - Metaprogramming with Groovy
 
Building fast interpreters in Rust
Building fast interpreters in RustBuilding fast interpreters in Rust
Building fast interpreters in Rust
 

Destacado

Common Online Terminologies
Common Online TerminologiesCommon Online Terminologies
Common Online Terminologieskirstinemorante
 
pesawa perkasa flight perkasa
pesawa perkasa flight perkasapesawa perkasa flight perkasa
pesawa perkasa flight perkasaChemal Ngablu
 
30 лет турбаза Аксаут - Красный Карачай 30 years Aksaut Nevinnomyssk
30 лет турбаза Аксаут - Красный Карачай 30 years Aksaut Nevinnomyssk 30 лет турбаза Аксаут - Красный Карачай 30 years Aksaut Nevinnomyssk
30 лет турбаза Аксаут - Красный Карачай 30 years Aksaut Nevinnomyssk Dmitry Selivanov
 
Project Bract Profile
Project Bract ProfileProject Bract Profile
Project Bract Profileprojectbract
 
Aktivitas perkasa flight school
Aktivitas perkasa flight schoolAktivitas perkasa flight school
Aktivitas perkasa flight schoolChemal Ngablu
 
penerimaan sertifikat flight perkasa
penerimaan sertifikat flight perkasapenerimaan sertifikat flight perkasa
penerimaan sertifikat flight perkasaChemal Ngablu
 
Համաշխարհային օվկիանոս
Համաշխարհային օվկիանոսՀամաշխարհային օվկիանոս
Համաշխարհային օվկիանոսNina Kirakosyan
 
5 13-1-menemukan-hal2-menarik-ttg-tokoh-cerita-rakyat
5 13-1-menemukan-hal2-menarik-ttg-tokoh-cerita-rakyat5 13-1-menemukan-hal2-menarik-ttg-tokoh-cerita-rakyat
5 13-1-menemukan-hal2-menarik-ttg-tokoh-cerita-rakyatDewan Gie
 
Կյանքի ծագումը և զարգացումը Երկրի վրա
Կյանքի ծագումը և զարգացումը Երկրի վրաԿյանքի ծագումը և զարգացումը Երկրի վրա
Կյանքի ծագումը և զարգացումը Երկրի վրաNina Kirakosyan
 

Destacado (12)

Presentation1
Presentation1Presentation1
Presentation1
 
Common Online Terminologies
Common Online TerminologiesCommon Online Terminologies
Common Online Terminologies
 
pesawa perkasa flight perkasa
pesawa perkasa flight perkasapesawa perkasa flight perkasa
pesawa perkasa flight perkasa
 
30 лет турбаза Аксаут - Красный Карачай 30 years Aksaut Nevinnomyssk
30 лет турбаза Аксаут - Красный Карачай 30 years Aksaut Nevinnomyssk 30 лет турбаза Аксаут - Красный Карачай 30 years Aksaut Nevinnomyssk
30 лет турбаза Аксаут - Красный Карачай 30 years Aksaut Nevinnomyssk
 
Project Bract Profile
Project Bract ProfileProject Bract Profile
Project Bract Profile
 
Pilot is my dream
Pilot is my dream   Pilot is my dream
Pilot is my dream
 
Aktivitas perkasa flight school
Aktivitas perkasa flight schoolAktivitas perkasa flight school
Aktivitas perkasa flight school
 
penerimaan sertifikat flight perkasa
penerimaan sertifikat flight perkasapenerimaan sertifikat flight perkasa
penerimaan sertifikat flight perkasa
 
Վիտամիններ
ՎիտամիններՎիտամիններ
Վիտամիններ
 
Համաշխարհային օվկիանոս
Համաշխարհային օվկիանոսՀամաշխարհային օվկիանոս
Համաշխարհային օվկիանոս
 
5 13-1-menemukan-hal2-menarik-ttg-tokoh-cerita-rakyat
5 13-1-menemukan-hal2-menarik-ttg-tokoh-cerita-rakyat5 13-1-menemukan-hal2-menarik-ttg-tokoh-cerita-rakyat
5 13-1-menemukan-hal2-menarik-ttg-tokoh-cerita-rakyat
 
Կյանքի ծագումը և զարգացումը Երկրի վրա
Կյանքի ծագումը և զարգացումը Երկրի վրաԿյանքի ծագումը և զարգացումը Երկրի վրա
Կյանքի ծագումը և զարգացումը Երկրի վրա
 

Similar a ios,objective tutorial

Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)
Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)
Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)Sarp Erdag
 
"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)
"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)
"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)AvitoTech
 
Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4DEVCON
 
can you add a delete button and a add button to the below program. j.pdf
can you add a delete button and a add button to the below program. j.pdfcan you add a delete button and a add button to the below program. j.pdf
can you add a delete button and a add button to the below program. j.pdfsales88
 
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual finalAhalyaR
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on AndroidSven Haiges
 
How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js ModuleFred Chien
 
What's new in C# 6 - NetPonto Porto 20160116
What's new in C# 6  - NetPonto Porto 20160116What's new in C# 6  - NetPonto Porto 20160116
What's new in C# 6 - NetPonto Porto 20160116Paulo Morgado
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Guillaume Laforge
 
Agile Iphone Development
Agile Iphone DevelopmentAgile Iphone Development
Agile Iphone DevelopmentGiordano Scalzo
 
連邦の白いヤツ 「Objective-C」
連邦の白いヤツ 「Objective-C」連邦の白いヤツ 「Objective-C」
連邦の白いヤツ 「Objective-C」matuura_core
 
Data structures lab manual
Data structures lab manualData structures lab manual
Data structures lab manualSyed Mustafa
 
Productaccess m
Productaccess mProductaccess m
Productaccess mAdil Usman
 
Tieto tdd from-dreams_to_reality_s.narkevicius_v.pozdniakov_2013 (1)
Tieto tdd from-dreams_to_reality_s.narkevicius_v.pozdniakov_2013 (1)Tieto tdd from-dreams_to_reality_s.narkevicius_v.pozdniakov_2013 (1)
Tieto tdd from-dreams_to_reality_s.narkevicius_v.pozdniakov_2013 (1)Agile Lietuva
 
Modernizes your objective C - Oliviero
Modernizes your objective C - OlivieroModernizes your objective C - Oliviero
Modernizes your objective C - OlivieroCodemotion
 

Similar a ios,objective tutorial (20)

Sbaw091006
Sbaw091006Sbaw091006
Sbaw091006
 
Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)
Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)
Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)
 
"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)
"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)
"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)
 
Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4
 
Advance java
Advance javaAdvance java
Advance java
 
can you add a delete button and a add button to the below program. j.pdf
can you add a delete button and a add button to the below program. j.pdfcan you add a delete button and a add button to the below program. j.pdf
can you add a delete button and a add button to the below program. j.pdf
 
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual final
 
C++ programs
C++ programsC++ programs
C++ programs
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
 
Data struture lab
Data struture labData struture lab
Data struture lab
 
How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js Module
 
What's new in C# 6 - NetPonto Porto 20160116
What's new in C# 6  - NetPonto Porto 20160116What's new in C# 6  - NetPonto Porto 20160116
What's new in C# 6 - NetPonto Porto 20160116
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008
 
Agile Iphone Development
Agile Iphone DevelopmentAgile Iphone Development
Agile Iphone Development
 
連邦の白いヤツ 「Objective-C」
連邦の白いヤツ 「Objective-C」連邦の白いヤツ 「Objective-C」
連邦の白いヤツ 「Objective-C」
 
Data structures lab manual
Data structures lab manualData structures lab manual
Data structures lab manual
 
Dartprogramming
DartprogrammingDartprogramming
Dartprogramming
 
Productaccess m
Productaccess mProductaccess m
Productaccess m
 
Tieto tdd from-dreams_to_reality_s.narkevicius_v.pozdniakov_2013 (1)
Tieto tdd from-dreams_to_reality_s.narkevicius_v.pozdniakov_2013 (1)Tieto tdd from-dreams_to_reality_s.narkevicius_v.pozdniakov_2013 (1)
Tieto tdd from-dreams_to_reality_s.narkevicius_v.pozdniakov_2013 (1)
 
Modernizes your objective C - Oliviero
Modernizes your objective C - OlivieroModernizes your objective C - Oliviero
Modernizes your objective C - Oliviero
 

Último

BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 

Último (20)

BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 

ios,objective tutorial

  • 1. Tutorial - 1 Mobile application development platforms, Android, Windows, iOS, Bada, Blackberry etc. Android, iOS, and Windows application development is high on demand and will remain for coming few years. Android/iOS and Windows application development is also possible using non standard tools. Android: eclipse + android sdk or Android Studio or Epselorator Studio (HTML5 + CSS3) or Phone Gap or TheAppBuilder.com etc. iOS: Xcode + MAC, Adobe, Appselorator Studio (HTML5 + CSS3) or Phone Gap or The App Builder etc. Blackberry: Eclipse + Blackberry SDK Windows: .NET Tutorial – 2 #import <Foundation/Foundation.h>
  • 2. int main (int argc, const char *argv[]) { @NSAutoreleasepool { NSLog(@"Hello world"); [pool drain]; return 0; } } Tutorial – 3 #import <Foundation/Foundation.h> int main (int argc, const char *argv[]) { @NSAutoreleasepool
  • 3. { int n1=20; int n2=40; int sum=n1+n2; NSLog(@"The sum of %i and %i is %i",n1,n2,sum); [pool drain]; return 0; } } Tutorial – 4 @interface Person:NSObject { int age; int weight; } -(void) print; -(void) setAge : (int) a; -(void) setWeight : (int) w;
  • 4. @end @implementation Person -(void) print { NSLog (@"I am %i years old and weigh %i pounds", age,weight); } -(void) setAge : (int) a { age=a; } -(void) setWeight : (int) w { weight=w; } @end int main (int argc, const char argv[]) { @NSAutoreleasepool {
  • 5. Person *ankit; ankit=[Person alloc]; ankit=[Person init]; [ankit setAge:20]; [ankit setWeight:100]; [ankit print]; return 0; } } Replacement in previous tutorial Tutorial: 5 Person *name= [[Person alloc]init]; Person *sandy=[[Person alloc]init]; [sandy setAge: 21]; [sandy setWeight:450]; [sandy print]; [sandy release]; [pool drain]; return 0;
  • 6. Tutorial – 6 Encapsulation @interface Person:NSObject { int age, int weight, } -(void) print; -(void) setAge : (int) a; -(void) setWeight : (int) w; -(int) age; -(int) weight; @end @implementation Person -(void) print { NSLog (@"I am %i years old and weigh %i pounds", age,weight); }
  • 7. -(int) setAge : (int) a { age=a; } -(int) setWeight : (int) w { weight=w; } -(int) age { return age; } -(int) weight { return weight; } @end int main(int argc, const char * argv[]) {
  • 8. @NSAutoreleaspool { Person *name= [[Person alloc]init]; [name setAge:25]; [name setWeight: 200]; NSLog(@"Name is %i and weighs %i", [name age],[name weight]); [name release]; [pool drain]; return 0; } } Tutorial – 7 Data Types #import <Foundation/Foundation.h> int main (int argc, const char *argv[]) {
  • 9. @NSAutoreleasepool { int i=20; float f=31.37; double d= 9/32; char c = ‘a’; NSLog (@"%i",i); NSLog (@"%f",f); NSLog (@"%e",d); NSLog (@"%c",c); [pool drain]; return 0; } } Tutorial – 8 TypeCasting #import <Foundation/Foundation.h> int main (int argc, const char *argv[]) { @NSAutoreleasepool {
  • 10. int i1, i2=15, i3=10; float f1=20.86, f2; i1=f1; NSLog (@"%i",i1); f2=i2/i3; NSLog (@"%f",f2); f2=f1/i3; NSLog (@"%f",f2); [pool drain]; return 0; } }
  • 11. Tutorial – 9 Type Casting (Explicite) #import <Foundation/Foundation.h> int main (int argc, const char *argv[]) { @NSAutoreleasepool { int i1, i2=15, i3=10; float f1=20.86, f2; f2=(float)i3/8; NSLog (@"%f",f2); int name = (int)22.77; NSLog (@"%i",name); name = name + 5; // name += 5; NSLog(@"%i", name); (Shorthand) name+=5; NSLog(@"%i", name);
  • 12. [pool drain]; return 0; } } LOOPS Tutorial – 10 For Loop:- #import <Foundation/Foundation.h> int main (int argc, const char *argv[]) { @NSAutoreleasepool { for(int i=1;i<=10;i++) NSLog(@"%i", i); [pool drain]; return 0; } } Tutorial – 11 #import <Foundation/Foundation.h>
  • 13. int main (int argc, const char *argv[]) { @NSAutoreleasepool { int i, usernumber; NSLog (@"Enter the number and I will print it"); scanf("%i",& usernumber); for(int i=1; i<= usernumber ; i++) NSLog(@"%i",i); [pool drain]; return 0; } }
  • 14. Tutorial – 12 Nested For Loop:- #import <Foundation/Foundation.h> int main (int argc, const char *argv[]) { @NSAutoreleasepool { int usernumber; for(int a=1; a<=3;a++) { NSLog(@"Enter a number"); scanf(“%i",&usernumber); for(int b=1; b<= usernumber; b++) NSLog(@"%i",usernumber); } [pool drain]; return 0; } }
  • 15. Tutorial – 13 While Loop:- #import <Foundation/Foundation.h> int main (int argc, const char *argv[]) { @NSAutoreleasepool { int num=1 ; while (num<=6) { NSLog(@"%i",num); num++; } [pool drain]; return 0; } }
  • 16. Tutorial – 14 #import <Foundation/Foundation.h> int main (int argc, const char *argv[]) { @NSAutoreleasepool { int num=1 ; int name; scanf(“%i",&name); while (num<=10) { NSLog(@"%i time %i= %i", num, name, num*name); num++; } [pool drain]; return 0; } } Tutorial – 15
  • 17. Do-While Loop:- #import <Foundation/Foundation.h> int main (int argc, const char *argv[]) { @NSAutoreleasepool { int n=1 ; do { NSLog(@"%i",n); n++; } while (n<=5); [pool drain]; return 0; } }
  • 18. Tutorial – 16 #import <Foundation/Foundation.h> int main (int argc, const char *argv[]) { @NSAutoreleasepool { int n=1 ; do { NSLog(@"%i squared is %i",n,n*n); n++; } while (n<=10); [pool drain]; return 0; } }
  • 19. Tutorial – 17 #import <Foundation/Foundation.h> int main (int argc, const char *argv[]) { @NSAutoreleasepool { int n,r ; NSLog(@"Enter a number"); scanf(“%i",&n); r=n%2; if(r==0) NSLog(@"Your number is even"); else NSLog(@"Your number is odd"); [pool drain]; return 0; } } Tutorial – 18 Relational test and nested if
  • 20. #import <Foundation/Foundation.h> int main (int argc, const char *argv[]) { @NSAutoreleasepool { int age,sex; NSLog(@"Enter age"); scanf(“%i",&age); NSLog(@"Enter sex (1:Boy 2:Girl)"); scanf(“%i",&sex); if (age<18 || age >80) NSLog(@"Go to another website"); else { if(sex==1) NSLog(@"Welcome Man!!"); else NSLog(@"Welcome Girl!!"); } [pool drain]; return 0; }
  • 21. } Tutorial – 19 Else if ladder #import <Foundation/Foundation.h> int main (int argc, const char *argv[]) { @NSAutoreleasepool { int time; NSLog(@"Enter the time"); scanf(“%i",&time); if(time<11) NSLog(@"Gud Morning!!"); else if(time<16) NSLog(@"Gud Afternoon!!"); else if(time<24) NSLog(@"Gud Night!!"); else NSLog(@"What did u enter????"); [pool drain];
  • 22. return 0; } } Tutorial – 20 Switch #import <Foundation/Foundation.h> int main (int argc, const char *argv[]) { @NSAutoreleasepool { int age=2; switch(age) { case 1: NSLog(@"They are cute"); break; case 2: NSLog(@"They are terrible"); break; case 3:
  • 23. NSLog(@"They are thirsty"); break; case 4: NSLog(@"They are 4"); break; default: NSLog(@"Enter valid number"); } } [pool drain]; return 0; } Tutorial – 21 Conditional Operator #import <Foundation/Foundation.h> int main (int argc, const char *argv[]) { @NSAutoreleasepool { int a=2,b=3,c=0;
  • 24. a==b ? NSLog(@"They are equal") : NSLog(@"They are different"); c ? NSLog(@"True") : NSLog (@"False"); } [pool drain]; return 0; } Tutorial – 22 MVC Architecture Person.h @interface Person:NSObject { int age,weight; } -(void) print; -(void) setAge : (int) a; -(void) setWeight : (int) w;//void setWeight(int w); @end
  • 25. Person.m #import “Person.h" @implementation Person -(void) print { NSLog (@"I am %i years old and weigh %i pounds", age,weight); } -(void) setAge : (int) a { age=a; } -(void) setWeight : (int) w { weight=w; } @end Main.m #import<Foundation/Foundation.h> #import “Person.h"
  • 26. int main (int argc, const char argv[]) { @NSAutoreleasepool { Person *name=[[Person alloc]init]; //Person ob = new Person(); [name setAge:20]; [name setWeight:100]; [name print]; [name release]; [pool drain]; return 0; } } Tutorial – 23 Automatic Setter& Getter Person.h @interface Person:NSObject { int age,weight; } @property int age,weight;
  • 27. -(void) print; @end Person.m #import "Person.h" @implementation Person @synthesis age,weight; -(void) print { NSLog(@"I am %iyears old and weigh %i pounds", age, weight); } @end Main.m #import<Foundation/Foundation.h> #import “Person.h" int main (int argc, const char argv[]) { @NSAutoreleasepool {
  • 28. Person *name=[[Person alloc]init]; name.age = 20; name.weight = 100; [name print]; [name release]; [pool drain]; return 0; } } Tutorial – 24 Multiple Arguments Person.h @interface Person:NSObject { int age,weight; } @property int age,weight; @end -(void) print; -(void) dateAge : (int) a : (int) i;
  • 29. Person.m #import"Person.h" -(void) print { NSLog(@"I am %iyears old and weigh %i pounds", age, weight); } -(void) dateAge : (int) a : (int) i { NSLog(@"You can date %i years old", (a/2+7)- (i/10000)); } Main.m #import <Foundation/Foundation.h> #import "Person.h" int main (int argc, const char argv[]) { @NSAutoreleasepool { Person *name=[[Person alloc]init];
  • 30. name.age = 12; name.weight = 120; [name print]; [name dateAge : 30:300000]; [name release]; [pool drain]; return 0; } } Tutorial – 25 Inheritance Main.m #import <Foundation/Foundation.h> @interface Lesley: NSObject { int a; } -(void) meth; @end @implementation Lesley
  • 31. -(void) meth { a=50; } @end @interface Son: Lesley -(void) printThing; @end @implementation Son -(void) printThing { NSLog(@"%i",a); } @end int main (int argc, const char argv[]) { @NSAotoreleasepool { son *s=[[son alloc]init]; [s meth]; [s printThing];
  • 32. [s release]; [pool drain]; return 0; } } Tutorial – 26 Rectangle.h @interface Rectangle:NSObject { int width, height; } @property int width,height; -(int) area; -(int) parameter; -(void) setWH : (int) w : (int) h; @end Rectangle.m #import “Rectangle.h" @implementation Rectangle @synthesize width,height; -(void) setWH : (int)w : (int)h
  • 33. { width=w; height=h; } -(int) area { return width*height; } -(int) parameter { return (width+height)*2; } @end Main.m #import <Foundation/Foundation.h> #import "Rectangle.h" int main (int argc, const char argv[]) { @NSAutoreleasepool { Rectangle *r=[[Rectangle alloc]init];
  • 34. [r setWH:6:8]; NSLog(@"Rectangle is %i by %i",r.width,r.height); NSLog(@"Area is %i, Parameter is %i",[r area],[r parameter]); [r release]; return 0; } } Tutorial – 27 Square.h #import “Rectangle.h" @interface Square:Rectangle -(void) setSide: (int)s; -(int) side; @end Square.m #import “square.h"
  • 35. @implementation Square: Rectangle -(void) setSide : (int)s { [self setWH :s:s]; } -(int) side { return width; } @end Main.m #import <Foundation/Foundation.h> #import “Square.h" int main (int argc, const char argv[]) { @NSAutoreleasepool { Square *s= [[Square alloc]init]; [s setSide:6]; NSLog(@"One side is %i", [s side]); NSLog(@"Area is %i and perameter is %i",[s area],[s parameter]);
  • 36. [s release]; [pool drain]; return 0; } } Tutorial – 28 Mom.h @interface Mom:NSObject { int num1; } -(void) setNum1; @end Mom.m #import “Mom.h" @implementation Mom -(void) setNum1 { num1=70; }
  • 37. @end Son.h #import “Mom.h" @interface Son:Mom -(void) setNum1; -(void)printNumber; @end Son.m #import “Son.h" @implementation Son -(void)setNum1 { num1= 14; } -(void)printNumber { NSLog(@"The number is %i",num1); } @end
  • 38. Main.m #import<Foundation/Foundation.h> #import “Son.h" int main (int argc, const char argv[]) { @NSAutoreleasepool { Son *s=[[Son alloc]init]; [s setNum]; [s printNumber]; [s release]; [pool drain]; return 0; } } Tutorial – 29 numz.h @interface numz:NSObject
  • 39. { int num1,num2,ans; } -(void) setNumbers : (int) a : (int) b; -(void) add; -(void) print; Numz.m @implementation Numz -(void) setNumbers: (int) a: (int) b { num1 = a; num2= b; } -(void) add { ans=num1+num2; } -(void) print { NSLog(@"I am from numz class, %i",ans); } @end
  • 40. charz.h @interface charz:NSObject { char c1; char c2; } -(void) setCharz; -(void)add; -(void)print; @end charz.m @implementation charz -(void) setCharz { c1=’B’; c2=’W’; } -(void) add { NSLog(@"%c %c",c1,c2); } -(void)print
  • 41. { NSLog(@"I am from the chaz class"); } Main.m #import<Foundation/Foundation.h> #import “numz.h" #import “charz.h" int main (int argc, const char argv[]) { @NSAutoreleasepool { numz *n =[[numz alloc]init]; charz *c =[[charz alloc]init]; [n setNumbers :8:10]; [n add]; [n print]; [c setCharz]; [c add]; [c print]; [n release];
  • 42. [c release]; [pool drain]; return 0; } } Tutorial – 30 numz.h @interface numz:NSObject { int num1,num2,ans; } -(void) setNumbers : (int) a : (int) b; -(void) add; -(void) print; Numz.m @implementation Numz -(void) setNumbers: (int) a: (int) b { num1 = a;
  • 43. num2= b; } -(void) add { ans=num1+num2; } -(void) print { NSLog(@"I am grom numz class, %i",ans); } @end charz.h @interface charz:NSObject { char c1; char c2; } -(void) setCharz; -(void)add; -(void)print; @end
  • 44. charz.m @implementation charz -(void) setCharz { c1=’B’; c2=’W’; } -(void) add { NSLog(@"%c %c",c1,c2); } -(void)print { NSLog(@"I am from the chaz class"); } Main.m #import<Foundation/Foundation.h> #import “numz.h" #import “charz.h" int main (int argc, const char argv[]) {
  • 45. @NSAutoreleasepool { numz *n =[[numz alloc]init]; charz *c =[[charz alloc]init]; [n setNumbers :8:10]; [n add]; [n print]; [c setCharz]; [c add]; [c print]; [n release]; [c release]; [pool drain]; return 0; } } Tutorial – 31 numz.h @interface numz:NSObject
  • 46. { int num1,num2,ans; } -(void) setNumbers : (int) a : (int) b; -(void) add; -(void) print; Numz.m @implementation Numz -(void) setNumbers: (int) a: (int) b { num1 = a; num2= b; } -(void) add { ans=num1+num2; } -(void) print { NSLog(@"I am grom numz class, %i",ans); } @end
  • 47. charz.h @interface chaez:NSObject { char c1; char c2; } -(void) setCharz; -(void)add; -(void)print; @end charz.m @implementation charz -(void) setCharz { c1=’B’; c2=’W’; } -(void) add
  • 48. { NSLog(@"%c %c",c1,c2); } -(void)print { NSLog(@"I am from the chaz class"); } Main.m #import<Foundation/Foundation.h> #import “numz.h" #import “charz.h" int main (int argc, const char argv[]) { @NSAutoreleasepool { id tuna; numz *n =[[numz alloc]init]; charz *c=[[charz alloc]init]; tuna=n;
  • 49. [tuna print]; tuna=c; [tuna print]; [pool drain]; return 0; } } Tutorial – 32 Exception Handling numz.h @interface numz:NSObject { int num1,num2,ans; } -(void) setNumbers : (int) a : (int) b; -(void) add; -(void) print; Numz.m @implementation Numz -(void) setNumbers: (int) a: (int) b {
  • 50. num1 = a; num2= b; } -(void) add { ans=num1+num2; } -(void) print { NSLog(@"I am grom numz class, %i",ans); } @end Main.m #import<Foundation/Foundation.h> #import “numz.h" int main (int argc, const char argv[]) { @NSAutoreleasepool { numz *n =[[numz alloc]init]; @try
  • 51. { [n this_is_gonna_get_error]; } @ catch (NSException *e) { NSLog(@"you got an error in your program"); } NSLog(@"this is the code after error"); [pool drain]; return 0; } } Tutorial – 33 Extern keyword tuna.h @interface tuna:NSObject -(void) changeVar; tuna.m @implementation tuna -(void) changeVar
  • 52. { extern int gdrunk; gdrunk=13; } Main.m #import<Foundation/Foundation.h> #import “tuna.h" int gdrunk=21; //Global Variable int main (int argc, const char argv[]) { @NSAutoreleasepool { tuna *f =[[tuna alloc]init]; [f changeVar]; NSLog(@"%i",gdrunk); [f release]; [pool drain]; return 0; } }
  • 53. Tutorial – 34 Enumerated Data Type main.m #import<Foundation/Foundation.h> int main (int argc, const char argv[]) { @NSAutoreleasepool { enum day {m,t,w,th,f}; enum day entry; NSLog(@"Enter the number for getting the day"); scanf(“%i",&entry); switch(entry) { case m: NSLog(@"Monday"); break; case t: NSLog(@"Tuesday"); break;
  • 54. case w: NSLog(@"Wednesday"); break; case th: NSLog(@"Thursday"); break; case f: NSLog(@"Friday"); break; default: NSLog(@"Enter the number within the range"); break; } } } Tutorial – 35 Define Statement crap.m #define BACON 23
  • 55. #define TOAST 44 main.m #import <Foundation/Foundation.h> #import “crap.h" int main(int argc, const char *argv[]) { @NSAutoreleasepool { int x= TOAST + BACON; NSLog(@"%i",x); [pool drain]; } } Tutorial – 36 Frameworks NSNumber main.m #import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepool
  • 56. { NSNumber *buckyint,*buckyfloat; buckyint=[NSNumber numberWithInteger:100]; buckyfloat=[NSNumber numberWithFloat:100.123]; int x=[buckyint intValue]; float y=[buckyfloat floatValue]; NSLog(@"%i and %f",x,y); if ([buckyint isEqualToNumber:buckyfloat]==YES) NSLog(@"They are equal"); else NSLog(@"They are not equal"); if ([buckyint compare :buckyfloat]==NSOrderedAscending) NSLog(@"First number is less"); else NSLog(@"Second Number is less"); return 0; } } Tutorial – 37 String Objects main.m #import <Foundation/Foundation.h> int main(int argc, const char * argv[])
  • 57. { @autoreleasepool { NSString *s=@"dont do this"; NSString *tester; printf("%@",s); NSLog(@"Length is %i",[s length]); tester=[NSString stringWithString:s]; NSLog(@"Copied string is %@",tester); tester=[s uppercaseString]; NSLog(@"%@", tester); } return 0; } Tutorial – 38 Substring main.m #import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepool
  • 58. { NSString *s = @"Cats dont like bananas"; NSString *d = @"Don’t feed grapes to dogs"; NSString *tester; tester = [d substringToIndex:10]; NSLog(@"First 10 characters are %@",tester); tester = [d substringFromIndex:10]; NSLog(@"From 10 till the end %@",tester); //tester = [d substringWithRange (5,11)]; //NSLog(@" %@",tester); NSRange range = [d rangeOfString:@"grapes"]; NSLog(@"Location is %i and length is %i", range.location,range.length); } return 0; } Tutorial – 39 Mutable String main.m #import <Foundation/Foundation.h>
  • 59. int main(int argc, const char * argv[]) { @autoreleasepool { NSString *dog = @"Hot dog "; NSMutableString *mute; mute = [NSMutableString stringWithString:dog]; NSLog(@"%@",mute); [mute insertString: @"sauce" atIndex:8]; NSLog(@"%@",mute); [mute deleteCharactersInRange: NSMakeRange(4,3)]; NSLog(@"%@",mute); } return 0; } Tutorial – 40 Mutable String main.m #import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepool { NSString *dog = @"Hot dog? I thought you said pumpkin"; NSMutableString *mute; mute = [NSMutableString stringWithString:dog];
  • 60. NSLog(@"%@",mute); [mute setString: @"I am a new string!"]; NSLog(@"%@",mute); [mute replaceCharactersInRange : NSMakeRange(11,7) withString :@"mother!"]; NSLog(@"%@",mute); NSString *old=@"mother"; NSString *new=@"baby seal"; NSRange therange = [mute rangeOfString:old]; [mute replaceCharactersInRange:therange withString:new]; NSLog(@"%@",mute); } return 0; } Tutorial – 41 Array main.m #import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepool {
  • 61. NSArray * food =[NSArray arrayWithObjects:@"apple",@"orang",@"mango",@"bana na", nil]; for(int i=0;i<4;i++) { NSLog(@"item at index %i is %@",i,[food objectAtIndex:i]); } } return 0; } Tutorial – 42 Mutable Array main.m #import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepool { NSMutableArray *changeme = [NSMutableArray arrayWithCapacity:25]; [changeme addObject: [NSNumber numberWithInteger:2]]; for(int i=0;i<=100;i++) {
  • 62. [changeme addObject:[NSNumber numberWithInteger:i]]; } for(int x=0;x<[changeme count];x++) { NSLog(@"%d=%li",x,(long)[[changeme objectAtIndex:x]integerValue]); } return 0; } } Tutorial – 43 Dictionaries main.m #import <Foundation/Foundation.h> int main(int argc, const char argv[]) { @NSAutoreleasepool { NSMutableDictionary *mydic = [NSMutableDictionary dictionary]; [mydic setObject:@"When you spray youself with free breez" forKey:@"freebreez shower"];
  • 63. [mydic setObject:@"gamer who lacks experience" forKey:@"Noob"]; [mydic setObject:@"worst food on the planet" forKey:@"sushi"]; NSLog(@"%@",[mydic objectForKey:@"sushi"]); } } Tutorial – 44 Files main.m #import <Foundation/Foundation.h> int main(int argc, const char argv[]) { @NSAutoreleasepool { NSString *testerfile = @"testerfile"; NSFileManager *manager; manager=[NSFileManager defaultManager]; //Creates a default file manager if([manager fileExistsAtPath : testerfile]==NO) {
  • 64. NSLog(@"File does not exists"); return 1; } // Copy of a file if ([manager copyItemAtPath : testerfile toPath:@"newfile" error : NULL]== NO) { NSLog(@"Cannot copy the file"); return 2; } //Rename the copy file if ([manager moveItemAtPath:@"newfile" toPath:@"newfile2" error:NULL]==NO) { NSLog(@"Cannot rename it"); return 3; }