Functor: Mapping over things!

Prelude Specialization is the key to mastery; functional programming specializes only on function. Thats all there is. The mastery with FP is to reduce complexity, which is what software engineering is all about. Don’t get me wrong, Software engineering is also about delivering product not only over engineering. Delivering real world products used to be the stressful part about functional programming. Not anymore. Specialization on functions creates a whole new paradigm.

Read More

Testing Network Calls with URLProtocol

URLProtocol and Unit Testing An NSURLProtocol object handles the loading of protocol-specific URL data. The NSURLProtocol class itself is an abstract class that provides the infrastructure for processing URLs with a specific URL scheme. You create subclasses for any custom protocols or URL schemes that your app supports. The main point is: All you have to do is define your protocol class and call the registerClass(_:) class method during your app’s launch time so that the system is aware of your protocol.

Read More

Why String Manipulation is alien in Swift3?

Objective-C era NSRange has a very simple API. Finding a range, replacing, splitting or chopping are some few tricks off the bat for simple string manipulation. Objective-C and its idiomatic NSRange API looks such: public struct _NSRange { public var location: Int public var length: Int } Lets say we wanted to extract just the name from a JSON string we got. let a: NSString = “name: Bj P.

Read More

Why is there AnyHashable in Swift3?

Evolution is predominant. Struggle for Survival applies to just anything that you see. Swift Programming Language is not an exception. Swift continues to change, evolve and mature over time. We can keep our feet wet, migrating year after year to Swift X version. I would. If it strives to be better. This years, Swift 2 -> Swift 3 was little more than a mini project. We saw lots of changes. For this edition, we will focus on [AnyObject: NSObject], which became [AnyHashable: Any].

Read More

Xcode8 ZStyle Code Formatter: How to write consistent styled code?

Yet again somebody missed to insert a empty line before the end of file, I missed to provide a empty space after dictionary Key [AnyHashable:Any] and you might miss to leave any of these kinds of code: //....... return data } func compute(a:Int,b:Int)->Int{ //....... Which should have been: //....... return data } func compute(a: Int, b: Int) -> Int { //....... So you see where I’m heading with this.

Read More