Home    |    Articles    |    Talks

MinionGenerator #Banana

Since the day I read this article and saw Natasha was using Minions for placeholder data, I started to do it, too. It’s hilarious to see these funny creatures on the places where users, clients or even bank officers are supposed to be.

Kevin Loan Officer

But how you get a Minion when you need him? Oh yeah, you need a Minion generator!

MinionGenerator is a struct with a few static functions:

// returns one Minion
static func randomMinion() -> Minion 

// returns array of random Minions
static func minions(count: Int) -> [Minion]

Minion, then, is a class looking like this:

class Minion: Equatable {
   let name: String
   let profilePicture: UIImage
   let profilePictureURL: NSURL


Usage is very simple:

let minion = MinionGenerator.randomMinion()
let arrayOfMinions = MinionGenerator.minions(15)

UITableViewController with Minions:

Minions example

Other assets

If you don’t need Minions, but some other random Minion-related data, you can use the following functions (their names are self-explanatory):

static func randomSentence() -> String
static func randomParagraph(sentences: Int) -> String     

static func randomPicture() -> UIImage 
static func randomPictures(count: Int) -> [UIImage]

static func randomPrictureURL() -> NSURL 
static func randomPictureURLs(count: Int) -> [NSURL] 


It’s obvious that once you start using MinionGenerator, your life will never be the same. Can’t wait? You can find the project’s GitHub repository here. (EDITED) The preferable way how to install MinionGenerator is by using Carthage. Add this line to your Cartfile

github "VojtaStavik/MinionGenerator"
Simply add this repository as a Git submodule, add ```MinionGenerator.swift``` and ```Minions.xcassets``` files to the Xcode project **(without copying it)**, and you’re good to go!

Note: This project should be used only for testing purposes. The code isn’t bulletproof at all, and it’s meant to crash if something goes to an undefined state (aka: exclamation marks everywhere ;-))

Source code of the project