2011年10月5日
摘要: objective-c 使用NSNumber 将int float long等数据类型加入到数组或字典中设置值和取值如下代码: NSNumber *number=[NSNumber numberWithInt:45]; NSLog(@"NSNumber %d",[number intValue]); 阅读全文
posted @ 2011-10-05 20:11 wtq 阅读(1347) 评论(0) 推荐(0) 编辑
摘要: 存储数据时,可以使用字典来存储,这样可以提高搜索速度。以下是创建字典的方法。NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys: @"wtq",@"name1", @"wtm",@"name2", @"wtp",@"name3", nil]; 将字典的值输出来。 NSLog(@"new dictionary is %@",[dic objectForKey:@"name2& 阅读全文
posted @ 2011-10-05 18:48 wtq 阅读(295) 评论(0) 推荐(0) 编辑
摘要: 通过NSEnumertor来遍历数组元素代码如下:NSArray *array=[NSArray arrayWithObjects: @"one",@"two",@"three",nil]; NSEnumerator *enumerator; enumerator = [array objectEnumerator]; id thing; while (thing=[enumerator nextObject]) { NSLog(@" I have get some value %@",thing); }使用快速遍 阅读全文
posted @ 2011-10-05 17:37 wtq 阅读(1366) 评论(0) 推荐(0) 编辑
摘要: //可变数组 NSMutableArray *ma = [NSMutableArray arrayWithCapacity:7]; [ma addObject: @"wtq"]; [ma addObject: @"wtp"]; [ma addObject: @"www"]; for (int i = 0; i<[ma count]; i++) { NSLog(@"value %@",[ma objectAtIndex:i]); } [ma addObject:@"wwttqq"]; NSL 阅读全文
posted @ 2011-10-05 17:20 wtq 阅读(748) 评论(0) 推荐(0) 编辑
摘要: 使用componentsSeparatedByString将字符串分隔成NSArray 数组代码如下: NSString *st = @"wta,wtb,wtc,wtd,wte,wtf,wtg,wth,wti,wtj"; NSArray *sarray = [st componentsSeparatedByString:@","]; for (int i=0; i<[sarray count]; i++) { NSLog(@"value:%@",[sarray objectAtIndex:i]); }使用componentsJo 阅读全文
posted @ 2011-10-05 16:32 wtq 阅读(587) 评论(0) 推荐(0) 编辑
摘要: 创建uilabel的代码如下- (void)viewDidLoad { [super viewDidLoad]; UILabel *lbWtq = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 150, 50)] autorelease]; lbWtq.text=@"this is my name"; //[lbWtq setText:@"text"]; [self.view addSubview:lbWtq]; } 阅读全文
posted @ 2011-10-05 11:25 wtq 阅读(405) 评论(0) 推荐(0) 编辑