This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class var sharedInstance { | |
struct Static { | |
static let instance : SingletonObject = SingletonObject() | |
static var onceToken : dispatch_once_t = 0 | |
} | |
dispatch_once(&Static.onceToken) { | |
//perform configuration here | |
} | |
return Static.instance | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Manages all the updates, inserts and deletes nicely so that you can worry about only the animation | |
/// @note Doesnt work with section changes as of yet | |
class CollectionViewFetchedResultsControllerDelegateCompanion: NSObject,NSFetchedResultsControllerDelegate { | |
var delegate: CollectionViewFetchedResultsControllerDelegateCompanionDelegate | |
private var changesKeyedByType:[NSFetchedResultsChangeType:[NSIndexPath]] = [:] | |
init(fetchedResultsController: NSFetchedResultsController,delegate: CollectionViewFetchedResultsControllerDelegateCompanionDelegate) { | |
self.delegate = delegate | |
super.init() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIView { | |
/// Returns a boolean indicating whether the view's width is currently in regular mode | |
/// On iOS 7 this will return true when the device is an iPad and false on iPhone | |
func isHorizontalSizeClassRegularWidth () -> Bool{ | |
if self.respondsToSelector("traitCollection") { | |
return self.traitCollection.horizontalSizeClass == UIUserInterfaceSizeClass.Regular | |
} else { | |
return UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xcodebuild -exportArchive -archivePath $projectname.xcarchive -exportPath $projectname -exportFormat ipa -exportProvisioningProfile “Provisioning Profile Name” |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
post_install do |installer| | |
require 'fileutils' | |
FileUtils.cp_r('Pods/Target Support Files/Pods/Pods-Acknowledgements.plist', 'Resources/Other-Sources/Settings.bundle/Acknowledgements.plist', :remove_destination => true) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// MagicalRecordLogging.h | |
// MagicalRecord | |
// | |
// Created by Saul Mora on 10/4/13. | |
// Copyright (c) 2013 Magical Panda Software LLC. All rights reserved. | |
// | |
#import <MagicalRecord/MagicalRecord+Options.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TweetViewController: UIViewController { | |
var initiatingPreviewActionController: UIViewController? | |
override func previewActionItems() -> [UIPreviewActionItem] { | |
guard let initiatingPreviewActionController = initiatingPreviewActionController else { | |
assert(false, "Expected initiatingPreviewActionController to be set") | |
return [] | |
} | |
return [UIPreviewAction(title: "Share", style: .Default, | |
handler: {[unowned self] (_, _) -> Void in | |
let shareSheet = self.createShareSheet() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@available(iOS 9.0, *) | |
extension TwitterFeedViewController: UIViewControllerPreviewingDelegate { | |
public func previewingContext(previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? { | |
guard let indexPath = collectionView.indexPathForItemAtPoint(location), | |
cell = collectionView.cellForItemAtIndexPath(indexPath), | |
let tweet = viewModel.tweetAtIndexPath(indexPath) else { return nil } | |
//now we are ready to create our corresponding controller for the tweet | |
let tweetViewController = self.navigationCoordinationController.tweetControllerForTweet(tweet) | |
//I will expand on this in a bit but this lets us present controllers using peek and pop actions | |
tweetViewController.initiatingPreviewActionController = self |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension MyViewController { | |
func registerForPeekAndPopWithCollectionView(collectionView: UICollectionView) { | |
guard #available(iOS 9.0, *) else { return } | |
if traitCollection.forceTouchCapability == .Available { | |
registerForPreviewingWithDelegate(self, sourceView: collectionView) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct AppInfo { | |
static func buildNumber() -> String { | |
return AppInfo.infoDictionary["CFBundleVersion"] as! String | |
} | |
static func versionNumber() -> String { | |
return AppInfo.infoDictionary["CFBundleShortVersionString"]as! String | |
} | |
private static var infoDictionary: [NSObject: AnyObject] { |
OlderNewer