Image for post
Image for post

In this short post, I will show you how to create a generic Networking API that you can reuse in your own implementations using generics and Combine. We won’t go in-depth of explaining elements of the Combine framework, instead, I will show you an example on how to use generics to boost your code reusability.

You will see here:

  1. Mix of generics and Combine Framework to create a reusable networking layer.
  2. Display elements from a network response in a SwiftUI list.

Don’t want to keep reading give me the code!. 😡

Let’s divide this into 3 simple steps…

Step 1: Build the generic networking layer.


Image for post
Image for post
https://developer.apple.com/design/human-interface-guidelines/ios/bars/sidebars/

Side bars are how we should create a hierarchical navigation system in iPad for non compact mode environments in iOS 14.

Ok , but what is actually a side bar? is just a view controller that has a collection view that uses the new side bar appearance list layout.

(Don’t want to read your stuff 😡, give me the code)

Since iOS 14 Apple introduced UICollectionLayoutListConfiguration an incredible improvement for UICollectionViews that allows us use a set of defined configurations for our collection views.

From the docs.

You create a sidebar by using a sidebar-style list and placing it in the primary column of a split view. …


Image for post
Image for post
Instagram iPad Prototype

In this post, we are going to talk about building for the iPad. We are going to use a prototype for Instagram to highlight key topics in how the OS manages its layout system to adapt to different iPad devices and to multitasking environments. Not sure why Instagram is not supported for iPad yet but I am sure it may not be far to be available. The prototype looks like this…


Image for post
Image for post

I don’t know you but this year WWDC left me with mixed feelings, on one hand, it made me feel already outdated and on the other, you know 🤯.

From Swift UI, to new ways of handling layout in collection views and managing Datasource states, the new features that are available for developers are just mind-blowing.

On this post, I will talk about one of the API enhancements that got me excited the most, Diffable DataSource. …


Image for post
Image for post
https://swapi.co/

Well, here we go again, one more time I will like to talk about generics and protocols in Swift 4.2.

A few days ago I gave me a small challenge, the goal? implement a client API for SWAPI the “Star Wars API”, made by Paul Hallett, avoiding code repetition as much possible but still keeping things making sense.

On this tutorial we will implement a client API using Swift Meta Types, Protocols with associated types, protocol inheritance, enums with associated values and of course generics, if any of this topics is not familiar to you I suggest stop here and check these resources. …


Image for post
Image for post
https://www.objc.io/books/functional-swift/

If you are an iOS developer you may hear about functional programming in Swift, but what is for real Functional programming? From Wiki

In computer science, functional programming is a programming paradigm — a style of building the structure and elements of computer programs — that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data.

It is not easy to give a straightforward explanation about this, however, think about it as instead of building a program in a sequence of assignments and function calls, emphasize it in repeatedly break it in smaller pieces that can be assembled using function application to define a complete program taking careful treatment of the state. …


Image for post
Image for post

Its been a while since I wrote “Protocol Based Generic Networking using JSONDecoder and Decodable in Swift 4” on that post I talked about how to use Decodable, protocols and generics to create a reusable networking layer.

It worked great but the API was limited to the GET HTTP method, that's why on this tutorial I want to extend it to use the POST method, I will do my best to show you how to use enums to do the job, I will assume that you didn’t read part 1 so I will start from zero in a new project and you can always go back to the first part for more details. …


Image for post
Image for post

Generics are one of the most powerful features of Swift, and much of the Swift standard library is built with generic code, it allows us to write clean and reusable code. Understanding its logic its not as straight forward than understanding its benefits and this post is not intended to explain them on detail, I think that is better to see how you can use it in a real component in your app, for this I am going to share with you a base implementation that you can reuse for any type.

We are going to create a base search controller, using generics and protocols polymorphism you will see how easy is to avoid code duplication in your code base. Lets start with a protocol that will help us to avoid dealing with strings in the view controller for reuse identifiers, create a new Project and create a new file and call it Reusable, copy and paste. …


Image for post
Image for post

WWDC 2018 is over, and it brought a lot of improvements in CoreML, ARKit, Swift, Xcode and so much more but with over 100 sessions is pretty hard to find the time to consume all the amazing content available,

I’ve been very lucky to be able to attend my first WWDC this year and be able to enjoy every hour of it, but let’s be honest, as busy developers as we are, we may not find enough time to watch every session online, that’s why I wanted to share with you short lists of “must watch videos” based on a certain topic and also based on sessions that I found awesome. …


Image for post
Image for post

This days Machine learning is the topic that everybody is talking about, there are so many resources online where you can use your camera and detect objects using pre-built models that Apple provides, very cool stuff for sure but it will be great if we iOS developers could create our own models and train them without needing some other engineer for that job, well…we can.

If you are not aware, IBM Watson studio is a very cool interface that let you create models and train them making able to your application perform visual recognition with a decent percentage of accuracy, I am going to show how to use IBM Watson Studio to train a model that detects if a picture belongs to a certain criteria, and we will build a simple app using Core ML and Vision to present the results. …

About

James Rochabrun

Senior iOS Engineer #latinintech

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store