Swift Challenge 11: Swipe controller

This was not my intended challenge, so it makes it even more interesting. I discussed with my classmates on the issue of swiping between view controllers, just a regular swipe as you see on most apps. How difficult could it be? Pretty difficult it turned out, not even our industry leader (senior mobile developer) had a straight answer.

What we did

We started googling and David from my class found this interesting project on github which mimics snapchat functionality. It worked exactly as we wanted (except for dots) but the code was not extendable or dynamic, so we thought we could change it.

How did it go?

It turned out pretty well, I removed a lot of code from appdelegate.swift and managed to squeeze it all in ViewController.swift.

What I did

First of all removed the vertical function, because it was not necessary for the functionality I was after. The second part was removing all duplicate code I kept finding everywhere because it was all very… unflexible. I needed to collect it all in an array: NSMutableArray which does some pretty cool things.

So how does NSMutableArray compare to NSArray? NSArray is for static objects and not dynamic objects, NSMutableArray allowed me to smack in some objects, such as the ViewControllers on the storyboard.

And here’s the complete code: https://github.com/joniden/Swift-challenges/tree/master/Swipe%20Controller

This whole code is just a refactor of: https://github.com/jakespracher/Snapchat-Swipe-View so if you’re interested, check it out.

That’s all for me!

Show your support

Clapping shows how much you appreciated Joacim Nidén’s story.