Hi List,
If I write a small loop, like the follwoing, to return an array of NSString encodings, it seems that the compiler reports erroneous errors....
NSMutableArray* array = [NSMutableArray array]; const NSStringEncoding* encoding = [NSString availableStringEncodings];
while (*encoding) { NSDictionary *encoding = [NSDictionary dictionaryWithObjectsAndKeys:[NSString localizedNameOfStringEncoding:*encoding],@"encodingName",[NSNumber numberWithInt:*encoding],@"encoding",nil]; [array addObject:encoding]; encoding++; }
At the line after "while (*encoding)" I get the following errors: incompatible type for argument 1 of ‘localizedNameOfStringEncoding: incompatible type for argument 1 of ‘numberWithInt:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
But if I write the following code:
NSMutableArray* array = [NSMutableArray array]; const NSStringEncoding* encoding = [NSString availableStringEncodings];
while (*encoding) { NSString *encodingName = [NSString localizedNameOfStringEncoding:*encoding]; NSNumber *encodingValue = [NSNumber numberWithInt:*encoding]; NSDictionary *encoding = [NSDictionary dictionaryWithObjectsAndKeys: encodingName,@"encodingName",encodingValue,@"encoding",nil]; [array addObject:encoding]; encoding++; }
Everything is fine.
It seems that the two are functionally the same... the other simply makes it more clear to the coder what is being passed in to -dictionaryWithObjectsAndKeys, but the compiler should already know that regardless....
Seems like a parsing bug??? |