Skip to content

Instantly share code, notes, and snippets.

@phileggel
phileggel / DeviceModel.swift
Created January 12, 2016 08:56
Check ios Current Device Model
// 1. Declare outside class definition (or in its own file).
// 2. UIKit must be included in file where this code is added.
// 3. Extends UIDevice class, thus is available anywhere in app.
// as per http://stackoverflow.com/a/27759550/5583117
//
// Usage example:
//
// if UIDevice().type == .simulator {
// print("You're running on the simulator... boring!")
// } else {
@phileggel
phileggel / PrettyBytes.swift
Last active September 5, 2019 11:37
Converting Int bytes info to user-friendly String
//
// From Jody Hagins
// http://stackoverflow.com/questions/10091816/nsfilesystemfreesize-translating-result-into-user-friendly-display-of-mb-gb
//
// Converted to swift by phil on 30/11/2015.
// Copyright © 2015 PhilEagleDev. All rights reserved.
//
func prettyBytes(numBytes: Int) -> String {
let scale: Double = 1024