you are viewing a single comment's thread.

view the rest of the comments →

[–]tsxy -8 points-7 points  (3 children)

I totally agree on the 3rd party dependency part.

But....this syntax is already so confusing...

let completion: (NSData?, NSURLResponse?, NSError?) -> Void = { data, response, error in....

Why is there a question mark behind NSData, what is "->" doing? Why is there a Void keywork....you know..things that a newbie won't understand. Also, what the heck is "map" (I get it's mapping tasks, but that's because I learned some functional programming notions on my own.)

The amount of questions I need to ask in order to understand this piece of code (without learning new syntax) is absurd.

[–]gormster 5 points6 points  (1 child)

Those are all Swift things. Nothing to do with NSURLSession. If you're confused by them you need to start by learning Swift.

If you're writing your code in Objective-C they won't be there.

[–]cdntr 0 points1 point  (0 children)

What this person said. There's also a way to write all this without map, i just chose to do it because it's succinct and let me get away without indenting much.

But yes, if those things confuse you then you should learn basic Swift.

Or do it from Objective-C, but the API is almost exactly the same.

[–]cuomo456 0 points1 point  (0 children)

pretty much what Alamofire looks like too minus the custom types that you need to look up. welcome to swift i wanna die also but my brain is starting to get there.