Image for post
Image for post
Coffee + Dev’n. The life.

noescape + Swift

My Deprecated Buddy

Jordan Morgan
Nov 25, 2016 · 5 min read

A quick note — all of my future posts will be published on my dedicated website and this publication is no longer being updated. Thanks for reading!

It’s Closure Time (…You Don’t Have To Go Home 🎶)

func asyncOp(completion:()->Void)
{
//Do some async networking call and then invoke completion()
}

What it Means To Escape

Async for Days

var onFakeCompletions:[()->()] = []
func fakeNetworkOp(_ completion:()->())
{
//Network stuff happens
completion()
}
func fakeNetworkOp(_ completion:()->())
{
//Network stuff happens
completion()
}
...later onfakeNetworkOp { print("Using a trailing closure, not a property") }
func fakeNetworkOp(_ completion:()->())
{
//Network stuff happens
onFakeCompletions.append(completion)
}
func fakeNetworkOp(_ completion:@escaping ()->())
{
onFakeCompletion.append(completion)
}

Default to Safety

Final Thoughts

Image for post
Image for post
😊
If you enjoyed this week's post, please feel free to go ahead and NSRecommend(this, where: below);

The Traveled iOS Developer’s Guide

Cocoa Touch, unwrapped and analyzed by @JordanMorgan10.

Jordan Morgan

Written by

iOS @buffer. Author for Pluralsight, contributor to a few books, conference talks and some other stuff! Writing at swiftjectivec.com

The Traveled iOS Developer’s Guide

Cocoa Touch, unwrapped and analyzed by @JordanMorgan10. Updated biweekly.

Jordan Morgan

Written by

iOS @buffer. Author for Pluralsight, contributor to a few books, conference talks and some other stuff! Writing at swiftjectivec.com

The Traveled iOS Developer’s Guide

Cocoa Touch, unwrapped and analyzed by @JordanMorgan10. Updated biweekly.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store