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 GetClassName { | |
class func getClassName(obj: AnyObject) -> String? { | |
return NSStringFromClass(obj.dynamicType)?.componentsSeparatedByString(".").last | |
} | |
class func getClassName(aClass: AnyClass) -> String? { | |
return NSStringFromClass(aClass)?.componentsSeparatedByString(".").last | |
} |
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
import UIKit | |
extension UIViewController { | |
class func instantiateFromStoryboard<T: UIViewController>() -> T { | |
if let name = NSStringFromClass(T.self)?.componentsSeparatedByString(".").last { | |
let storyboard: UIStoryboard = UIStoryboard(name: name, bundle: nil) | |
if let vc = storyboard.instantiateInitialViewController() as? T { | |
return vc | |
} |
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
for i in 1...100{print((i%3>0 ?i%5>0 ?String(i):"":"Fizz")+(i%5>0 ?"":"Buzz"))} |
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
new-podspec () { | |
if [ $# -lt 1 ] | |
then | |
echo "Library name required." | |
exit 1 | |
fi | |
: ${2:=1.0.0} | |
cat <<PODSPEC > "$1.podspec" | |
Pod::Spec.new do |s| | |
s.name = "$1" |
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
public protocol EnhancedErrorType: ErrorType, CustomStringConvertible { | |
var domain: String { get } | |
var code: Int { get } | |
var userInfo: [NSObject: AnyObject]? { get } | |
} | |
extension EnhancedErrorType { | |
var _domain: String { | |
return domain | |
} |
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
enum ValidationResult { | |
case Success | |
case Failure(ValidationErrorType) | |
} | |
enum ValidationErrorType: ErrorType { | |
case WrongLength(Int) // マイナンバーの桁数(文字数)が不正の場合 | |
case NotANumber // 数字以外が含まれている場合 | |
case InvalidNumber // 検査して不正なマイナンバーだった場合 | |
} |
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
import RxSwift | |
import RxCocoa | |
public extension UIScrollView { | |
public var rx_reachedBottom: Observable<Bool> { | |
return rx_contentOffset.map { $0.y == (self.contentSize.height - self.frame.height) } | |
} | |
} |
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
let view = UIView(frame: CGRectZero) | |
// ↓ | |
let view = UIView(frame: CGRect.zero) | |
// ↓ | |
let view = UIView(frame: .zero) |
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
# rules | |
#- colon | |
#- control_statement | |
#- file_length | |
#- force_cast | |
#- function_body_length | |
#- leading_whitespace | |
#- line_length | |
#- nesting | |
#- operator_whitespace |
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
public protocol FilePathConvertible { | |
var filePath: String { get } | |
var fileURL: NSURL { get } | |
} | |
extension String: FilePathConvertible { | |
public var filePath: String { | |
return self | |
} | |
public var fileURL: NSURL { |
OlderNewer