Dictionary
Traverse dictionary
NSLog (@ "*** traverse the dictionary myClassDict as follows :");
For (id key in myClassDict)
{
NSLog (@ "key: % @, value: % @", key, [myClassDict objectForKey: key]);
}
[_ SurveyAnswers1 setObject: myArrayAnswers1 forKey: @ "FirstKey"];
For (NSString * key in [cacheDict allKeys]) {}
Array
Quickly create an array
// NSMutableArray * array = [NSMutableArray arrayWithObjects: @ "One", @ "Two", @ "Three", nil];
[_ List addObjectsFromArray: [indexlist copy];
_ FilteredList = [_ stringList filteredArrayUsingPredicate: [NSPredicatepredicateWithFormat: @ "SELF contains [cd] % @", searchString];
/* ------------- Array enumeration ---------------*/
//-(NSEnumerator *) objectEnumerator; forward and backward
// NSMutableArray * array = [NSMutableArray arrayWithObjects:
@ "One", @ "Two", @ "Three", nil];
NSEnumerator * enumerator;
Enumerator = [array objectEnumerator];
Id thingie;
While (thingie = [enumerator nextObject]) {
NSLog (@ "thingie: % @", thingie );
}
//-(NSEnumerator *) reverseObjectEnumerator; forward from the back
// NSMutableArray * array = [NSMutableArray arrayWithObjects:
@ "One", @ "Two", @ "Three", nil];
NSEnumerator * enumerator;
Enumerator = [array reverseObjectEnumerator];
Id object;
While (object = [enumerator nextObject]) {
NSLog (@ "object: % @", object );
}
NSStringrang. location Points to the first character @ "//".
Nsange range;
Range = [url rangeOfString: @ "//"];
If (range. length> 0 ){
Url = [url substringFromIndex: range. location + range. length];
}
Extract range = [url rangeOfString: @ "/"];
If (range. length> 0 ){
Url = [url substringFromIndex: range. location + 1];
}
Intercepted to #, not included #
Range = [url rangeOfString: @ "#"];
If (range. length> 0 & range. location> 0 ){
Url = [url substringToIndex: range. location];
}
Modulename = [nsstringstringwithuf8string :( * itStr). c_str ()];
NSString * welcomeInfo = [@ "welcome back" stringByAppendingString: nickName]; NSString * servantCmd = [NSString stringWithFormat: @ "wnsxms. % @", @ "getcommandlist"];