Wednesday, 15 August 2012

Foundation Framework

Foundation Framework :-  A framework is collection of methods ,classes and documentation logically grouped together to make the developing easier.
                                                           The Foundation framework introduces several paradigms to avoid confusion in common situations, and to introduce a level of consistency across class hierarchies.

The Foundation class hierarchy is rooted in the Foundation framework’s NSObject class.

Cocoa Objective-C Hierarchy for Foundation :-

         












 Work in some classes  
NSNumber :-

Integer
NSNumber  *num1=[[NSnumber alloc]initWithValue:100];
NSInteger myInt;
myInt=[num IntergerValue];
NSLog(@"integer is =%@",myInt);

Char

myNumber = [NSNumber numberWithChar: ‘X’];
NSLog (@"%@",[myNumber  CharValue];

 Similar to the float/long/double.

Equal

if ([intNumber isEqualToNumber: floatNumber] == YES)
NSLog (@
”Numbers are equal”);
else
NSLog (@”Numbers are not equal”);


 NSString & NSMutableString :-

you created a character string object in Objective-C.The Foundation framework supports
a class called
NSString for working with character string objects.

NSString *str = @"Programming is fun";
NSLog (@”%@, str);


Ex:-
NSString *sh = @"This is string A";

NSString *sh1 = @This is string B;
NSString *sha";  


number of charactersNSLog (@Length of sh: %@, [sh length]);
Copy one string to another

sha = [NSString stringWithString: sh];
NSLog (@
copy: %@, sha);

Copy one string to the end of another

sh1 = [sh stringByAppendingString: sh1];
NSLog (@
Concatentation: %@, sh1);

Equal

if ([sh isEqualToString: sha] == YES)
NSLog (@ sh == sha);

else
NSLog (@ ”sh != res);


In Mutable string

[sh InsertString:@"hello"AtIndex:2];
[Sh InssertString @"end"AtIndex:[sh1 Length]]

NSArray & NSMUtableArray  :-

A Foundation array is an ordered collection of objects. Most often, elements in an array
are of one particular type, but that’s not required. Just as there are mutable and immutable
strings, are there mutable and immutable arrays.
Immutable arrays are handled by theNSArray class, whereas mutable ones are handled by NSMutableArray.

NSArayy *arr=[[NSArray alloc]initWithObjects:@"india",@"pak",@"uk",@''lanka''@"us",nil];
for(int i=0; i<=5, i++){
NSLog(@"%@",[arr AtIndex:i]);
}

MutableArray:-

NSMutable *arr=[[NSMutalbelArray alloc]init];
[arr addObject:@"india"];
[arr addObject”sh != res);
NSLog(@"%@",[arr ObjectAtIndex:1]);

[arr InsertObject :@"ram in" AtIndex:3]



NSDictionary & NSMutableDictionary :-

A dictionary is a collection of data consisting of key-object pairs.

NSm\MutableDictionary *obj =[NSMutableDictionary obj]
[obj SetObjects:@"indore" forKey:@"i"];
[obj SetObjects:@"kanpur" forKey:@"k"];
[obj SetObjects:@"nagpur" forKey:@"n"];

NSLog(@"%@",[obj ObjectKey:@"i"]);






No comments:

Post a Comment