Yeah, there doesn't seem to be an elegant way to do it, so I gave up and used a var.
> On Jul 7, 2015, at 01:31 , Quincey Morris > <quinceymor...@rivergatesoftware.com> wrote: > > On Jul 7, 2015, at 01:21 , Rick Mann <rm...@latencyzero.com> wrote: >> >> let thumbURL: String? >> for imgD in images >> { >> if let isHero = imgD["is_hero"] as? Bool where isHero, >> let t = imgD["thumbnail_signed_src"] as? String >> { >> thumbURL = t >> break >> } >> } > > You’ve still got a path where ‘thumbURL’ is uninitialized — when ‘images’ is > empty. I’m not sure if there’s an elegant way to do it, but you can do it by > brute force something like this: > >> do >> { >> var url: String? = nil >> >> for imgD in images >> { >> if let isHero = imgD["is_hero"] as? Bool where isHero, >> let t = imgD["thumbnail_signed_src"] as? String >> { >> url = t >> break >> } >> } >> >> thumbURL = url >> } -- Rick Mann rm...@latencyzero.com _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com