Re: Value of type '[AnyObject]!' has no member 'Generator'
Re: Value of type '[AnyObject]!' has no member 'Generator'
- Subject: Re: Value of type '[AnyObject]!' has no member 'Generator'
- From: Roland King <email@hidden>
- Date: Sun, 04 Oct 2015 14:03:28 +0800
> On 4 Oct 2015, at 13:48, Rick Mann <email@hidden> wrote:
>
> Why won't this compile?
>
> let devices = AVCaptureDevice.devices() // OKAY
> for device in devices
> {
> print("Device: \(device)")
>
> for f in device.formats // no member "Generator"
> {
> print(" format: \(f)")
> }
> }
>
> Each of the loops' collections is of type [AnyObject]! But for the device.formats, I get
>
> AppDelegate.swift:25:13: Value of type '[AnyObject]!' has no member 'Generator'
>
> Also, command-clicking on device() takes me to a Swift interface file. Command-clicking on formats takes me to an Objective-C header.
>
> If I put a ! after device.formats, it compiles.
>
> --
> Rick Mann
> email@hidden
>
Apply the usual swift technique and break it down into more than one line then go look at the types of each variable.
let ff = device.formats
let pp = ff!
option-click on each of those variables and you’ll quickly see the ‘!!’ on the first one and hence why you have to explicitly unwrap it to get it into a [AnyObject] which has a generator.
_______________________________________________
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