• 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
Re: Swift Compiler Bug?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Swift Compiler Bug?


  • Subject: Re: Swift Compiler Bug?
  • From: Roland King <email@hidden>
  • Date: Mon, 15 Sep 2014 11:00:07 +0800

> On 15 Sep 2014, at 10:47 am, Charles Jenkins <email@hidden> wrote:
>
> Now on to the next thing that doesn’t seem to work according to the documentation…
>
> These are the first few lines of my function which will save my document data:
>
>  override func fileWrapperOfType(
>    typeName: String!,
>    error outError: NSErrorPointer
>  ) -> NSFileWrapper!
>  {
>    if self.theFileWrapper == nil {
>      let noWrappers: [AnyObject] = []
>      self.theFileWrapper = NSFileWrapper( directoryWithFileWrappers: noWrappers )
>
>    }
>
>
> When I start typing “directoryWithFileWrappers,” Xcode displays its suggestion list showing the prototype:
>
> NSFileWrapper( directoryWithFileWrappers: [NSObject : AnyObject] )
>
> I think I could send nil instead of bothering to create an empty array, but whatever.
>
> Anyway, Xcode gives me the prototype which agrees with Apple’s documentation, and I code according to it. Then Xcode marks the line as an error: “Missing argument for parameter ‘options’ in call,” and my project won’t build.
>
> Is there an error in my code, or is this a problem I should report to Apple? And in the latter case, what’s the best way?
>

There’s an error in your code, that’s not an array, it’s a dictionary. [ NSObject : AnyObject ] so your noWrappers is of the wrong type, you don’t even need to make it a variable either if you don’t want

NSFileWrapper( directoryWithFileWrappers: [:] )

note the colon

or

let noWrappers:[NSObject:AnyObject]=[:]
NSFileWrapper( directoryWithFileWrappers:[:] )

or

let noWrappers = [NSObject:AnyObject]()
NSFileWrapper( directoryWithFileWrappers:[:] )

or a number of other versions depending on how verbose you wish to be.

Please feel free to file a bug report about the terrible error messages the swift compiler tosses out which are entirely unhelpful and often lead in entirely the wrong direction. These days I treat almost any error message from the swift compiler as if it says ‘Syntax Error’ and don’t try to use the message to find the issue.


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


References: 
 >Swift Compiler Bug? (From: Charles Jenkins <email@hidden>)

  • Prev by Date: Swift Compiler Bug?
  • Next by Date: Re: Swift Compiler Bug?
  • Previous by thread: Swift Compiler Bug?
  • Next by thread: Re: Swift Compiler Bug?
  • Index(es):
    • Date
    • Thread