class Person: Object {
dynamic var identifier = ""
// ネストはOptionalで定義
dynamic var unit: Unit?
// 配列はList (Documentではletだが、ObjectMapperを使うためにvar)
var dogs = List<Dog>()
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
//: Playground - noun: a place where people can play | |
//: Markup Format | |
// Heading # | |
/*: | |
# Heading1 in Block |
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
// This method can only be a nop if the transition is interactive and not a percentDriven interactive transition. | |
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext{ | |
UIViewController* fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; | |
UIViewController* toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; | |
UIView* fromView = fromVC.view; | |
UIView* toView = toVC.view; | |
UIView* containerView = [transitionContext containerView]; | |
CGRect inframe = [transitionContext initialFrameForViewController:fromVC]; |
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
// http://natecook.com/blog/2014/07/swift-options-bitmask-generator/ | |
struct UnuseOptions : OptionSetType { | |
typealias RawValue = UInt | |
private var value: UInt = 0 | |
init(_ value: UInt) { self.value = value } | |
init(rawValue value: UInt) { self.value = value } | |
init(nilLiteral: ()) { self.value = 0 } | |
static var allZeros: UnuseOptions { return self.init(0) } | |
static func fromMask(raw: UInt) -> UnuseOptions { return self.init(raw) } | |
var rawValue: UInt { return self.value } |
- xcprojを作る
- podfileを記述
- pod install
- workspace開く
- add > new > playground
- Manage SchemeでPods-プロジェクト名にチェックを付ける
- "Pods-プロジェクト"をビルド
- playgroundでimport
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 | |
import RealmSwift | |
import XCPlayground | |
class BusStop: Object { | |
dynamic var identifier = "" | |
dynamic var name = "" | |
convenience init(identifier: String, name: String) { | |
self.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
let objType = array.dynamicType.Element.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
typealias ResponseType = [CardList] | |
// ResponseTypeをうまく使えてないのがアレだが・・ | |
func fromJson(json: AnyObject) -> Result<GetCardList.ResponseType, NSError> { | |
guard let dictionary = json as? [[String : AnyObject]] else { | |
return .Failure(Error.errorWithCode(2, failureReason: "[CardList]のマッピングに失敗しました")) | |
} | |
var array = [CardList]() | |
dictionary.forEach { |
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 Foundation | |
import ObjectiveC | |
private var LangBundleKey = 0 | |
// Thanks for a following post | |
// http://www.factorialcomplexity.com/blog/2015/01/28/how-to-change-localization-internally-in-your-ios-application.html | |
extension NSBundle { | |
private class BundleEx: NSBundle { | |
OlderNewer