Avoiding Double Stuffed View Controllers in MVC

Imagine you’re building a house. After months of waiting you sit down with the architect to see the plans. Unfortunately there’s a problem. Everything you asked for is there but it’s all in one giant room! “I can’t take a poo in front of my spouse. It’s a line we don’t cross.” – you remark. Just as designing a building requires dedicated rooms for dedicated  purposes so does code. Model-View-Controller is a way to architect code into 3 distinct layers that achieve 3 separate purposes. Along with compartmentalizing code MVC also lays out a structure for how these layers should communicate with each other. The nature of Apple’s UIKit framework makes it easy to separate objects in the view layer from the controller layer. However, because it’s not strictly enforced, there’s a tendency to put app logic and data in the vcs (view controllers), leaving them looking “double stuffed”.

The Strong, the Weak and the Unowned

It’s the Fall of 2011, Adele’s “Rolling in the Deep” is blasting from little white headphones everywhere. It was a simpler time, except in the area of iOS memory management. Something was about to change. With iOS5 came the wonder of Automatic Reference Counting (ARC). App memory management became a lot easier. However, there are still a few scenarios which, if left unchecked, could have you “Rolling in the S***”.

Cloud Storage with AWS S3 – Part 2: Using the SDK

In the previous blog we covered an introduction to S3 storage, created an S3 bucket and did a simple download using NSURLSession. The issue with that is that the image file had to have public access. This means that anyone with the URL would be able to download the contents of the bucket. In reality it’s not a great idea to have such open access. In order to have control over what users can do to your S3 buckets it’s necessary to grasp a few other exciting AWS services. These being; Cognito and IAM. As well as this we’ll cover using CocoaPods to install the AWS SDK. If you’re thinking: that sounds like a hot tamale! Don’t worry, we’ll break it into smaller, bit size tamales.

Cloud Storage with AWS S3 – Part 1

Beside the power, scalability and low cost of cloud computing, one of the most exciting aspects of Amazon Web Services is how easy is it to experiment with. At first the AWS console can look like daunting array of icons and services (SimpleElasticBeanFace…coming soon?) However, it’s much easier to play around with and learn than back in the days of running your own hardware servers. Plus there’s already a massive global infrastructure of data centers at your disposal! Simple Storage Solution, S3, is a prefect starting point to get your feet wet (or should I say: head wet in the cloud). This blog will cover how to upload an image via the AWS console and download it using Swift in iOS. Even before delving into the AWS Swift SDK, downloading images/video/JSON from S3 into an app is quite straightforward.

Getters and Setters Described Using Letters

Values are associated with classes, structs and enums using properties. Properties can come in two forms, the simplest being a stored property. Thankfully Swift makes life a little simpler than in the Objective-C world by doing away with instance variables. In Swift the functionality of Objective-C iVars and properties are brought together into a single property declaration.  This comes as either a constant (let) or variable (var) and can be assigned a default value where they’re declared, or thair value can be set or modified at initialization.

Optionals Toolbox Essentials

Optionals are the keystone in the Swift Cathedral of Safety. They protect against the possibility of a value being absent, the program looking for that value and then crashing. Welcome to a guide through 6 useful tools used to navigate the landscape of question marks, exclamations marks (and even double question marks??)! When a value is optional it means that it can be in one of two states: 1) it contains something or 2) it contains nil. In fact optionals in Swift are enums with two cases: .None, or .Some<t>. Optionals are a distinct type and the compiler wont let them be used until the value has been “unwrapped”.