Subscribe to The infinite monkey theorem

Stay up to date! Get all the latest & greatest posts delivered straight to your inbox

swift

Has nothing to do with Objective C .

Cheat sheet cover image
swift

Cheat sheet

Just a bunch of short expressions in Swift.

Positioning views relative to one another with auto-layout cover image
xcode,  auto-layout,  swift

Positioning views relative to one another with auto-layout

Positioning views relative to one another with auto-layout was fairly tricky until...

Stack views vertically or horizontally on iOS 8 using AutoLayout cover image
ios,  auto-layout,  swift

Stack views vertically or horizontally on iOS 8 using AutoLayout

While starting iOS 9 we have UIStackView, it is a little bit tricky to stack views vertically or horizontally.

Using guard to test for an empty string cover image
swift

Using guard to test for an empty string

In Swift, we have a syntax candy called 'guard'..

Debugging view constraints with Xcode 7 cover image
xcode,  objc,  swift,  auto-layout

Debugging view constraints with Xcode 7

A small button named 'Debug view hierarchy', displays current view hierarchy in 3D.

VIPER architecture cover image
swift,  architecture,  viper

VIPER architecture

Decouple, separate, disengage, or dissociate (something) from something else.

Debugging xxx was deallocated while key value observers were still registered with it cover image
swift,  xcode

Debugging xxx was deallocated while key value observers were still registered with it

Debugging errors that are a result of observers being added to an object and not removed from it can be hard.

Catching an exception in Swift using functions! cover image
swift

Catching an exception in Swift using functions!

Recently we had a need in a general way to catch calls that can throw an exception.

Creating NSManagedObject subclasses from a model in Xcode 8 cover image
xcode,  swift,  ios

Creating NSManagedObject subclasses from a model in Xcode 8

In Xcode 8, it is no longer possible to create NSManagedObject subclasses...

Compiler Error when using Generics and nested functions, Command failed due to signal: Segmentation fault: 11 cover image
swift,  ios,  xcode

Compiler Error when using Generics and nested functions, Command failed due to signal: Segmentation fault: 11

The following code is causing a compiler crash when compiled with Swift 3 and Xcode 8...

A simple optimization for UICollectionView (or UITableView) updates cover image
swift,  ios

A simple optimization for UICollectionView (or UITableView) updates

Collection view is highly optimized and works great out of the box.

A very important difference between a Signal and a SignalProducer cover image
reactive-swift,  reactive-cocoa,  swift

A very important difference between a Signal and a SignalProducer

A property in ReactiveSwift allows us to track its changes over time.

Working with a playground cover image
swift,  reactive-swift,  reactive-cocoa,  ios

Working with a playground

According to the documentation, to use ReactiveSwift.playground the following steps must be performed...

Flatten and some of its strategies cover image
swift,  reactive-swift

Flatten and some of its strategies

The power of ReactiveSwift lies within its operators.!

UICollectionView terminating with uncaught exception of type NSException cover image
xcode,  ios,  swift

UICollectionView terminating with uncaught exception of type NSException

ne of our views that contains a UICollectionView started crashing once in a while...

Unwanted padding in UICollectionView in iOS 10 cover image
swift,  ios,  auto-layout

Unwanted padding in UICollectionView in iOS 10

On iOS 10, a collection view embedded in a view has unexpected padding at the top.

Use of unresolved identifier 'Resources' cover image
rx-swift,  swift,  cocoa-pods

Use of unresolved identifier 'Resources'

RxSwift.Resources are being used to detect memory leaks during pre release tests. Solving Use of unresolved identifier 'Resources' error.

UICollectionView: Self sizing cell with a UILabel on iOS 10 cover image
swift,  ios

UICollectionView: Self sizing cell with a UILabel on iOS 10

All we needed was a simple UICollectionView with just one cell that contained a label ...

Setting height constraint for a view in a cell cover image
ios,  swift,  auto-layout

Setting height constraint for a view in a cell

We needed a collection view cell that contained an image view and a label.

How to avoid memory leaks cover image
rx-swift,  swift,  ios

How to avoid memory leaks

RxSwift is a powerful framework and, as always, with power comes responsibility.

Framework with C code cover image
swift,  ios,  xcode

Framework with C code

How to create a framework that uses C with Xcode

UIScrollView with AutoLayout, programmatically cover image
swift,  auto-layout

UIScrollView with AutoLayout, programmatically

It is fairly easy to use UIScrollView with the AutoLayout on iOS 12+ but only if one follows the following steps ...

Should one always use weak self to avoid retain cycles? cover image
swift

Should one always use weak self to avoid retain cycles?

It has become pretty common among Swift experts to always use [weak self] inside of a closure to avoid retain cycles ...

A useful extension of XCTestCase cover image
swift

A useful extension of XCTestCase

XCTest expectations are great but it is not easy to use them.

Dependency injection explained cover image
swift

Dependency injection explained

Why do we need to inject dependencies and some tools that help with it...