This file contains hidden or 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 | |
protocol OptionalType { | |
associatedtype Wrapped | |
var optional: Wrapped? { get } | |
} | |
extension Optional : OptionalType { | |
var optional: Wrapped? { return self } | |
} |
This file contains hidden or 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 Struct { | |
func method() {} | |
} | |
enum Enum { case a } | |
class Class { | |
func method() {} | |
} | |
func compareSelf<T: Any>(_ target: T) { | |
print(target, type(of: target), (target as AnyObject) === (target as AnyObject)) |
This file contains hidden or 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 | |
let aName = Notification.Name(rawValue: "a") | |
struct Struct { let id: Int } | |
let structAsAny1 = Struct(id: 1) as AnyObject | |
let structAsAny2 = Struct(id: 2) as AnyObject | |
let structAsAny3 = Struct(id: 3) as AnyObject |
This file contains hidden or 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 structAsAny1 = Struct(id: 1) as Any | |
let notification = Notification(name: aName, object: structAsAny1, userInfo: nil) | |
(notification as AnyObject) === (notification as AnyObject) //false | |
(structAsAny1 as AnyObject) === (structAsAny1 as AnyObject) //false | |
let structAsAnyObject = Struct(id: 1) as AnyObject | |
(structAsAnyObject) === (structAsAnyObject) //true |
This file contains hidden or 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 | |
let aName = Notification.Name(rawValue: "a") | |
struct Struct { let id: Int } | |
extension Struct: Equatable { | |
public static func ==(lhs: Struct, rhs: Struct) -> Bool { | |
return lhs.id == rhs.id | |
} | |
} |
This file contains hidden or 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 | |
let aName = Notification.Name(rawValue: "a") | |
struct Struct: Equatable { | |
let id: Int | |
static func ==(lhs: Struct, rhs: Struct) -> Bool { | |
print("\(lhs.id) vs \(rhs.id) = \(lhs.id == rhs.id)") | |
// 👆ログに出ない。ってことは、この == 、呼ばれてない! | |
return lhs.id == rhs.id |
This file contains hidden or 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 aName = Notification.Name(rawValue: "a") | |
class Class {} | |
struct Struct {} | |
enum Enum { | |
case a, b | |
} | |
let aClass = Class() | |
let aStruct = Struct() |
This file contains hidden or 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 aName = Notification.Name(rawValue: "a") | |
class Class {} | |
struct Struct {} | |
enum Enum { | |
case a, b | |
} | |
let aClass = Class() | |
let aStruct = Struct() |
This file contains hidden or 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
[Notifwift]@23:41 % gem uninstall --all --executables cocoapods | |
ERROR: While executing gem ... (Gem::InstallError) | |
cocoapods is not installed in GEM_HOME, try: | |
gem uninstall -i /Users/tksk_mba/.rvm/gems/ruby-2.2.1@global cocoapods | |
[Notifwift]@23:42 % gem uninstall -i /Users/tksk_mba/.rvm/gems/ruby-2.2.1@global cocoapods | |
Select gem to uninstall: | |
1. cocoapods-1.0.1 | |
2. cocoapods-1.1.0.rc.2 | |
3. All versions |
This file contains hidden or 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
func check(_ target: Any, as name: String, at method: String) { | |
print(" \(method)\(name) =") | |
print(" 👔 \(type(of: target))") | |
print(" 🍖 \(target)") | |
} | |
final class SubClassOfNSObject: NSObject { | |
override init() { | |
print("🌱init start") | |
super.init() |