1,
NSString *name = [[NSString alloc]initwithstring:@ "Zhang San"];
NSLog (@ "%d", [name Retaincount]);
2014-11-27 20:43:20.290 OC Exam wrong question [1750:303]-1
2,
nsstring* testobject = [[NSData alloc] init];
Compile-time, nsstring type, run-time, NSData type
3,
Nsarray * (^ablock) (NSString * str,nsstring *str2);
Declares a block type variable with a return value of Nsarray and a two string object
4,
Nsmutabledictionary * dic = [[Nsmutabledictionary alloc] initwithobjectsandkeys:@ "1", @ "2", @ "2", @ "3", @ "3", @ "4", nil];
Nsarray *arr = [[Nsarray alloc] initwitharray:[dic AllKeys]];
NSString *str = [[NSString alloc] Initwithformat:[arr objectatindex:0],[arr Objectatindex:1],[arr ObjectAtIndex:2]];
NSLog (@ "%@", str);
2014-11-27 20:47:22.678 OC Exam wrong question [1761:303] 2
5,
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *sstr = [NSString stringwithformat:@ "abc"];
NSString *STR2 = [sstr retain];
[Pool release];
NSLog (@ "Sstr Retaincount =%ld,str2 Retaincount =%ld", [Sstr retaincount],[str2 retaincount]);
Sstr Retaincount = 1,str2 Retaincount = 1
6,
Nsmutabledictionary * Dic1 = [[Nsmutabledictionary alloc] initwithobjectsandkeys:@ "1", @ "2", @ "1", @ "3", @ "1", @ "4", nil];
Nsarray *arr1 = [[Nsarray alloc] Initwitharray:[dic1 AllKeys]];
Nsarray *ARR2 = [[Nsarray alloc] Initwitharray:[dic1 allvalues]];
Nsmutabledictionary *dic2 = [[Nsmutabledictionary alloc] initwithobjects:arr1 FORKEYS:ARR2];
NSLog (@ "%@", Dic2);
1 = 4;
7, replace @ "2B youth" with @ "literary youth"
Nsrange Range1 = {0,2};
[@ "2B Youth" Stringbyreplacingcharactersinrange:range1 withstring:@ "literary"];
8,
Nsmutabledictionary * dic3 = [[Nsmutabledictionary alloc] initwithobjectsandkeys:@ "1", @ "2", @ "2", @ "3", @ "3", @ "4", nil];
[Dic3 setobject:@ "1" forkey:@ "3"];
[Dic3 removeobjectforkey:@ "1"];
NSLog (@ "%@", DIC3);
2 = 1;3 = 1;4 = 3;
9, in the class method, the instance variable can be used by BU.
10, instance objects are generated by invoking a class method.
return 0;
Objective-c wrong question