The second code example ("if you were doing this before ARC") is completely wrong. "alloc" is a class method that allocates memory for an instance, on which "init" is then called. Calling it on an instance returned by a factory method is nonsensical.
The error is made consistently all three times, so it's clear that the author is genuinely confused about Objective-C. Maybe he's better at Swift, but it doesn't look good.
The author is Ash Furrow, who has written numerous Obj-C books and apps. I highly doubt he's confused about Obj-C; he'll probably turn up in this thread at some point though, so it may be worth asking.
I'm a bit curious as to why people talk about "protocol oriented" as something new. It seems to me to be just a way of doing interface-oriented programming, like people coding in java have been doing for the last ten years, as well as golang dev, and many other languages... Am i missing a difference, or is it just not to confuse people that only develop in objective-c ?
Is the currying example even currying? It looks like it's just a function returning a function to me. I thought currying it's some thing like func contains(subString: String, string: String) -> Bool, and calling contains("a") would automatically return a func(x: String) -> Bool.
Currying refers to the process of taking a function that accepts multiple arguments, and turning it into a sequence of functions, each accepting a single argument. The example you provide would be more aptly described as partial application, which is the process of fixing a number of arguments to a function, producing a function of smaller arity.
I use this style myself. It is way easier to read than `!condition`. If you are scanning the code, a single `!` at the beginning of the condition won't stand out that much.
[+] [-] Camillo|10 years ago|reply
The error is made consistently all three times, so it's clear that the author is genuinely confused about Objective-C. Maybe he's better at Swift, but it doesn't look good.
[+] [-] holyjaw|10 years ago|reply
[+] [-] interpol_p|10 years ago|reply
[+] [-] thealistra|10 years ago|reply
[+] [-] martind81|10 years ago|reply
[+] [-] bsaul|10 years ago|reply
[+] [-] sinhpham|10 years ago|reply
[+] [-] bdash|10 years ago|reply
[+] [-] AshFurrow|10 years ago|reply
I think the people in this thread discussing how my stylistic choices are "wrong" may have missed my point. Too bad.
[+] [-] mjmsmith|10 years ago|reply
[+] [-] florian_buerger|10 years ago|reply
[+] [-] holyjaw|10 years ago|reply
EDIT: Or maybe even just a hastily typed example code
[+] [-] andyfleming|10 years ago|reply
[+] [-] bdash|10 years ago|reply