Consuming API The Good, the Bad and the Ugly
Don’t reinvent the wheelUse libraries!
Can we improve it?
• Not reusable
• What if there is some authorization?
• Common error handling?
API ManagerACHIEVEMENT UNLOCKED
Data (de)serializationACHIEVEMENT UNLOCKED
Creating objects from JSON
[User userWithDictionary:(NSDictionary*)dict]
[UserFactory createUserWithDictionary:(NSDictionary*)dict]
Alternatives
• KZPropertyMapper • Mantle • JSONModel
Let’s just paste the new parsing code everywhere, or….
Abstraction is nice
• Network engine independent
• Easy to use
• Extendable
Categories to the rescue!
ALAMOFIREis the new AFNetworking
More complicated is more complicated*
* - If you are begginer in swift