On Jun 29, 2015, at 5:53 PM, Rick Mann <rm...@latencyzero.com> wrote:
> 
>> If you are using Swift 2.0, you can use the new `guard let` to get optional 
>> checking without the cascade of indentation.
>>   guard let url = NSURL(string: "<some url>")
>>   else { /* handle failure and either halt or return */ }
>>   // URL is now in scope and non-optional.
>>   let req = NSURLRequest(URL: url)
> 
> I am, but this may not work as well if there are additional steps after this 
> one that should run anyway. Can I enclose the bit in braces to limit the 
> scope of the break? Probably not, huh? e.g.:
> 
> {
>    guard let url = ... else { break }
>    <use url>
> }
> 
> {
>    ...other init...
> }

Look into the “defer” keyword.

Charles

_______________________________________________

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

Reply via email to