Re: Swift Compiler Bug?
Re: Swift Compiler Bug?
- Subject: Re: Swift Compiler Bug?
- From: Charles Jenkins <email@hidden>
- Date: Mon, 15 Sep 2014 07:24:59 -0400
Duhhhhhhhhhh! I have created dictionaries already—there’s a sample one for testing in my app already—but the syntax of that prototype went right over my head. I’m accustomed to JSON and Python’s use of braces to declare dictionaries, and I was so fully convinced the variable was an array that I misunderstood it as NSObject: [AnyObject] every time I saw and typed it.
Ordinarily I’m not quite this dumb, but as you can see I’m not completely used to the syntax yet. I wish Apple had chosen braces, but perhaps that would have created needless confusion with closures.
Thank you to everyone who answered my silly question! :-)
--
Charles
On Sunday, September 14, 2014 at 23:04, Quincey Morris wrote:
> On Sep 14, 2014, at 19:47 , Charles Jenkins <email@hidden (mailto:email@hidden)> wrote:
>
> > 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.
>
> No, the parameter isn’t an optional type, so you can’t pass nil.
> > 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?
>
> The parameter is a *dictionary*, not an array. IIRC you can specify an empty dictionary as ‘[:]’, so there’s no real need for a supplementary variable.
>
> If that’s the error that’s being reported on, then it’s being mis-reported. That’s probably worth a bug report.
>
_______________________________________________
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