WEB开发网
开发学院手机开发iPhone 开发 NSString+NSMutableString+NSValue+NSAraay用法汇... 阅读

NSString+NSMutableString+NSValue+NSAraay用法汇总

 2010-09-16 23:54:00 来源:WEB开发网   
核心提示://NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:@"One",@"1",@"Two",@"2",@"Three",@&q

//NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:@"One",@"1",@"Two",@"2",@"Three",@"3",nil];

NSString *string = [dictionary objectForKey:@"One"];

NSLog(@"string:%@",string);

NSLog(@"dictionary:%@",dictionary);

[dictionary release];

/********************************************************************************

NSMutableDictionary

********************************************************************************/

/*------------------------------------创建可变字典 ------------------------------------*/

//创建

NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];

//添加字典

[dictionary setObject:@"One" forKey:@"1"];

[dictionary setObject:@"Two" forKey:@"2"];

[dictionary setObject:@"Three" forKey:@"3"];

[dictionary setObject:@"Four" forKey:@"4"];

NSLog(@"dictionary:%@",dictionary);

//删除指定的字典

[dictionary removeObjectForKey:@"3"];

NSLog(@"dictionary:%@",dictionary);

/******************************************************************************

NSValue(对任何对象进行包装)

****************************************************************************/

/*--------------------------------将NSRect放入NSArray中 ------------------------------------*/

//将NSRect放入NSArray中

NSMutableArray *array = [[NSMutableArray alloc] init];

NSValue *value;

CGRect rect = CGRectMake(0, 0, 320, 480);

value = [NSValue valueWithBytes:&rect objCType:@encode(CGRect)];

[array addObject:value];

NSLog(@"array:%@",array);

//从Array中 提取

value = [array objectAtIndex:0];

[value getValue:&rect];

NSLog(@"value:%@",value);

/**************************************************************************

上一页  1 2 3 4 5 6 7 8 9 10  下一页

Tags:NSString NSMutableString NSValue

编辑录入:coldstar [复制链接] [打 印]
赞助商链接