1
iOS 앱용 기능이 있습니다. 있는 NSString value
및 key
그러나 [data setValue:value forKey:key]
변경 가능한 사전의 키에 값 할당
-(NSMutableDictionary *)parseCode:(NSString *)string{
NSArray *array = [string componentsSeparatedByString:@"||"];
NSMutableDictionary *data;
for(id object in array){
NSArray *objectAndKey = [object componentsSeparatedByString:@"::"];
NSString *key =[objectAndKey objectAtIndex:0];
NSString *value = [objectAndKey objectAtIndex:1];
[data setValue:value forKey:key];
[self alertMeWithString:[data valueForKey:key]];
}
return data;
}
초급 실수를 사용하여 전화를 걸 수 있습니다. 대부분의 다른 언어와 달리 Objective-C에서는 nil 포인터를 호출해도 오류가 발생하지 않지만 단순히 0/nil을 반환합니다. –
관련 항목 : [NSMutableDictionary에서 setObject : forKey :와 setValue : forKey :의 차이점은 무엇입니까?] (0120-385-305) – dasblinkenlight