Skip to content

Instantly share code, notes, and snippets.

View wanbok's full-sized avatar
🎯
Focusing

Wanbok Choi (Wayne) wanbok

🎯
Focusing
View GitHub Profile
@wanbok
wanbok / gist:99a25c6480056f4db15c
Last active August 29, 2015 14:14
모달뷰 띄우고 내리는 테스트 케이스: TestCase for presenting and dismissing (Modal)ViewController
- (void)setUp {
[super setUp];
[RKTestFactory setUp];
[RKManagedObjectStore setDefaultStore:[RKTestFactory managedObjectStore]];
appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
storeCollectionViewController = [(UINavigationController *)appDelegate.window.rootViewController viewControllers][0];
createStoreViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"CreateStoreViewController"];
}
- (void)tearDown {
@wanbok
wanbok / gist:0535c6d63bf50d7be5ab
Last active August 29, 2015 14:14
TestCase for UIBarButtonItem
UIBarButtonItem *cancelButton = createStoreViewController.cancelButton;
XCTAssertEqual(cancelButton.target, createStoreViewController, @"UIBarButtonItem 검증");
XCTAssertTrue([NSStringFromSelector(cancelButton.action) isEqualToString:@"onCancel:"], @"UIBarButtonItem 검증");
class CollectionViewController: UICollectionViewController {
var sectionChanges: [[NSFetchedResultsChangeType: Int]]? = nil
var itemChanges: [[NSFetchedResultsChangeType: AnyObject]]? = nil
...
}
// MARK: NSFetchedResultsControllerDelegate
@wanbok
wanbok / ViewControllerWithTableView_NSFetchedResultsControllerDelegate.swift
Last active August 29, 2015 14:15
Swift: NSFetchedResultsControllerDelegate for UITableView
class ViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
...
}
// MARK: - NSFetchedResultsControllerDelegate
extension ViewController: NSFetchedResultsControllerDelegate {
func controllerWillChangeContent(controller: NSFetchedResultsController) {
self.tableView.beginUpdates()
@wanbok
wanbok / CombineString.swift
Last active August 29, 2015 14:18
Swift, Joining (Implicitly Unwrapped) Optional Strings with a joiner
extension String {
func join(strings: String!... ) -> String {
return self.join(strings.filter({ $0?.isEmpty == false }).map {$0 as String})
}
}
extension UIButton {
private var normalBackgroundColor: UIColor? {
get {
return objc_getAssociatedObject(self, &NormalBackgroundColorKey) as? UIColor
}
set(newValue) {
objc_setAssociatedObject(self,
&NormalBackgroundColorKey, newValue, .OBJC_ASSOCIATION_RETAIN)
@wanbok
wanbok / XIBTemplateView.swift
Created November 19, 2015 05:53
XIB UIView template with Autolayout
//
// XIBTemplateView.swift
// JanuaryEffect
//
// Created by Wanbok on 2015. 11. 18..
// Copyright © 2015년 JanuaryEffect. All rights reserved.
//
import UIKit
//
// MockingServer.swift
// Frip
//
// Created by 최완복 on 2016. 1. 6..
// Copyright © 2016년 Wanbok. All rights reserved.
//
import UIKit
import AMYServer
@wanbok
wanbok / CopyableLabel.swift
Last active May 23, 2017 03:39
Copyable UILabel
//
// CopyableLabel.swift
//
// Created by Wanbok Choi on 2016. 3. 17..
//
import UIKit
final class CopyableLabel: UILabel {
@wanbok
wanbok / UISearchControllerDelegateExtension.swift
Created April 25, 2016 06:46
UISearchControllerDelegate
extension ViewController: UISearchControllerDelegate {
func willPresentSearchController(searchController: UISearchController) {
tabBarController?.tabBar.hidden = true
searchBarBackground(true)
dimmingBackground(true)
}
func willDismissSearchController(searchController: UISearchController) {
tabBarController?.tabBar.hidden = false
searchBarBackground(false)