프로그래밍/iOS
NSMutableDictionary 사용법 및 삽입 ,삭제에 대해서 알아보자
백룡화검
2011. 6. 2. 01:47
1. NSMutableDictionary 생성 및 add 방법
//생성
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
//item add
[dictionary setObject:@"A Book about the Letter A" forKey:@"A"];
[dictionary setObject:@"A Book about the Letter B" forKey:@"B"];
[dictionary setObject:@"A Book about the Letter C" forKey:@"C"];
2. NSMutableDictionary remove 방법
// 전체 루프를 돌면서 각각의 아이템 삭제 작업을 해줘야합니다
for (id theKey in dictionary ) {
item = [[dictionary objectForKey:theKey] retain];
[item removeFromSuperview];
[item release];
item = nil;
}
[dictionary removeAllObjects];
[ dictionary release];
[ dictionary release];