wymsee / cordova-HTTP

Cordova / Phonegap plugin for communicating with HTTP servers. Allows for SSL pinning!
MIT License
372 stars 301 forks source link

refactoring common code and avoiding dictionary's setObject with nil #143

Open ccdatatraits opened 7 years ago

ccdatatraits commented 7 years ago

According to https://developer.apple.com/documentation/foundation/nsmutabledictionary/1411616-setobject?language=objc -> "Raises an NSInvalidArgumentException if anObject is nil. If you need to represent a nil value in the dictionary, use NSNull." I have come across a situation when errResponse came out as nil and because of that my app was breaking. And I saw the same code repeatedly used 5 times so I refactored into a single private method. I have never really written a proper ObjC code so you could let me know best practices if you wish. Kindly test at your end 👍