티스토리 뷰

딕셔너리에 string int long 등이 있을때 element 타입체크하기.

for(NSString *key in mDict)
{
  id value = [mDict objectForKey:key];
  if([value isKindOfClass:[NSString class]]) {
    NSString *temp = (NSString*)value;
    NSLog(@"%@",temp);
  }
  else if([value isKindOfClass:[NSNumber class]]) {
    NSNumber *numTemp = (NSNumber*)value;
    NSString *strTemp = [numTemp stringValue];
    NSLog(@"%@",strTemp);
  }
}
댓글