Skip to content

Instantly share code, notes, and snippets.

@kevinrandrup
kevinrandrup / Enum - allValues.swift
Last active March 24, 2016 21:17
Swift enum - allValues
import UIKit
/// Summary
/// Add an allValues function to all enums that are RawRepresentable
/// to access, iterate over, and count all of the values of an enum.
/// The usage is general enough that I believe it would be a great addition to the language.
///
/// Having an allValues method would only be logical for enums which do not have associated values.
/// This limits the enum to RawRepresentable enums and basic enums.
@kevinrandrup
kevinrandrup / CDCameraViewController.swift
Created September 27, 2015 13:44
UIViewController that uses AVFoundation to display camera input
/*
The MIT License (MIT)
Copyright (c) 2015 Kevin Randrup
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@kevinrandrup
kevinrandrup / CDPhotoCollectionView.swift
Created September 27, 2015 13:39
UICollectionViewController displaying image thumbnails for iOS 8+
/*
The MIT License (MIT)
Copyright (c) 2015 Kevin Randrup
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@kevinrandrup
kevinrandrup / ArrayUtil.swift
Last active January 25, 2016 20:42
A few convenience methods on the Swift array to fill in some of the missing API gaps.
/**
The MIT License
Copyright (c) 2015 Kevin Randrup
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@kevinrandrup
kevinrandrup / UIViewController+AlertMessage.swift
Last active January 25, 2016 20:42
One liner to create and show an alert message using UIAlertController (iOS 8.0+)
/**
The MIT License (MIT)
Copyright (c) 2015 Kevin Randrup
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@kevinrandrup
kevinrandrup / MapKitZoom.swift
Last active January 25, 2016 20:43
Zoom an MKMapKit to the user's location
/**
The MIT License (MIT)
Copyright (c) 2015 Kevin Randrup
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@kevinrandrup
kevinrandrup / DictionaryMerge.swift
Last active January 25, 2016 20:41
Merge correctly typed Swift dictionary into another dictionary.
/**
The MIT License
Copyright (c) 2015 Kevin Randrup
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is