• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Why does the following refuse to compile?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why does the following refuse to compile?


  • Subject: Why does the following refuse to compile?
  • From: email@hidden
  • Date: Sun, 24 Sep 2006 10:31:47 -0700

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???
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Why does the following refuse to compile?
      • From: David Dunham <email@hidden>
    • Re: Why does the following refuse to compile?
      • From: Fritz Anderson <email@hidden>
  • Prev by Date: Re: glitch upgrading from Xcode 2.0 to 2.4
  • Next by Date: Re: Why does the following refuse to compile?
  • Previous by thread: Re: Debugger has become dysfunctional for my project.
  • Next by thread: Re: Why does the following refuse to compile?
  • Index(es):
    • Date
    • Thread