The framework refers to Objective-c's foundation library, which gives several common classes and their methods in the following example.
NSNumber *Intnum; NSNumber*Longnum; NSNumber*Floatnum; Intnum= [NSNumber Numberwithinteger: A]; NSLog (@"%i", [Intnum IntegerValue]); Longnum= [NSNumber Numberwithlong:0x123456]; NSLog (@"%LX", [Longnum Longlongvalue]); Floatnum= [NSNumber numberwithfloat:12.00]; NSLog (@"%f", [Floatnum Floatvalue]); if([intnum isequaltonumber:floatnum] = =YES) {NSLog (@"Eqaul");//same}Else{NSLog (@"Not equal"); }
NSString *STR1 =@"Hello,world"; NSString*STR2 = [NSString stringWithFormat:@"%i,%@",5,@"Fredric"]; NSLog (@"%@%@", STR1,STR2); NSLog ([str1 stringbyappendingstring:str2]); Nsmutablestring*STR3 = [nsmutablestring stringwithstring:@"Hello"]; [Str3 appendString:@"Fredric_"]; [Str3 insertstring:@"Word"AtIndex:str3.length]; NSLog (@"%@", STR3);//Hellofredric_wordNsrange Res= [STR3 rangeofstring:@"Ric"]; if(Res.location! =nsnotfound) {[Str3 deletecharactersinrange:res]; } NSLog (@"%@", STR3);//Hellofred_word
Nsarray *array = [Nsarray arraywithobjects:@"Demo1",@"Demo2",@"Demo3", nil]; for(inti =0; i < [array count]; i++) {NSLog (@"%@", [array objectatindex:i]); } Nsmutablearray*marray = [Nsmutablearray arraywithcapacity:3]; [Marray AddObject:@"Demo4"]; [Marray AddObject:@"Demo5"]; [Marray AddObject:@"Demo6"]; for(inti =0; i < [Marray count]; i++) {NSLog (@"%@", [Marray objectatindex:i]); }
Nsdictionary *dic = [Nsdictionary Dictionarywithobjectsandkeys:@"value1",@"Key1",@"value2",@"Key2",@"VALU3",@"Key3", nil]; NSString*value1 = [dic objectforkey:@"Key1"]; NSLog (@"%@", value1); Nsmutabledictionary*mdic =[[Nsmutabledictionary alloc]init]; [MDic setobject:@"value1_1"Forkey:@"Key1"]; NSLog (@"%@", [MDic Objectforkey:@"Key1"]);
Objective-c (frame)