Skip to content

Instantly share code, notes, and snippets.

View ryanmaxwell's full-sized avatar

Ryan Maxwell ryanmaxwell

  • Auckland, New Zealand
View GitHub Profile
@kristopherjohnson
kristopherjohnson / KeyboardNotification.swift
Last active October 6, 2023 14:45
Swift convenience wrapper for the userInfo values associated with a UIKeyboard notification
import UIKit
/// Wrapper for the NSNotification userInfo values associated with a keyboard notification.
///
/// It provides properties that retrieve userInfo dictionary values with these keys:
///
/// - UIKeyboardFrameBeginUserInfoKey
/// - UIKeyboardFrameEndUserInfoKey
/// - UIKeyboardAnimationDurationUserInfoKey
/// - UIKeyboardAnimationCurveUserInfoKey
@marcprux
marcprux / XCTAssertEqualOptional.swift
Created July 23, 2014 17:48
XCTAssertEqual that handles optional unwrapping
/// like XCTAssertEqual, but handles optional unwrapping
public func XCTAssertEqualOptional<T: Any where T: Equatable>(expression1: @auto_closure () -> T?, expression2: @auto_closure () -> T?, _ message: String? = nil, file: String = __FILE__, line: UInt = __LINE__) {
if let exp1 = expression1() {
if let exp2 = expression2() {
XCTAssertEqual(exp1, exp2, message ? message! : "", file: file, line: line)
} else {
XCTFail(message ? message! : "exp1 != nil, exp2 == nil", file: file, line: line)
}
} else if let exp2 = expression2() {
XCTFail(message ? message! : "exp1 == nil, exp2 != nil", file: file, line: line)
@MrRooni
MrRooni / gist:4988922
Created February 19, 2013 19:16
UITableView and NSFetchedResultsController: Updates Done Right
@interface SomeViewController ()
// Declare some collection properties to hold the various updates we might get from the NSFetchedResultsControllerDelegate
@property (nonatomic, strong) NSMutableIndexSet *deletedSectionIndexes;
@property (nonatomic, strong) NSMutableIndexSet *insertedSectionIndexes;
@property (nonatomic, strong) NSMutableArray *deletedRowIndexPaths;
@property (nonatomic, strong) NSMutableArray *insertedRowIndexPaths;
@property (nonatomic, strong) NSMutableArray *updatedRowIndexPaths;
@end
@adamgit
adamgit / .gitignore
Last active April 8, 2024 12:58
.gitignore file for Xcode4 / OS X Source projects
#########################
# .gitignore file for Xcode4 and Xcode5 Source projects
#
# Apple bugs, waiting for Apple to fix/respond:
#
# 15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation?
#
# Version 2.6
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
@sekati
sekati / xcode-build-bump.sh
Created July 24, 2012 20:44
Xcode Auto-increment Build & Version Numbers
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)