Last active
October 19, 2018 01:55
-
-
Save casademora/d0510802c62a46053b35e4503fbe7637 to your computer and use it in GitHub Desktop.
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 | |
//To try out this code, copy and paste into a new Xcode playground. | |
import UIKit | |
class Operation: NSObject | |
{ | |
let nextOperation: Operation? | |
init(next: Operation? = nil) | |
{ | |
self.nextOperation = next | |
} | |
override func forwardingTarget(for aSelector: Selector!) -> Any? | |
{ | |
print(String(describing: self)) | |
return nextOperation | |
} | |
} | |
class FirstHandlerType: Operation | |
{ | |
func doSomething() | |
{ | |
print("Did: ".appending(String(describing: self))) | |
} | |
} | |
class SecondHandlerType: Operation | |
{ | |
} | |
class ThirdHandlerType: Operation | |
{ | |
} | |
let first = FirstHandlerType() | |
let second = SecondHandlerType(next: first) | |
let third: AnyObject = ThirdHandlerType(next: second) //add and remove AnyObject to see how Xcode handles the change. | |
third.doSomething() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Casedemora,
The function doSomething() needs @obj dynamic keywords prefixed to be working correctly. Please correct me if wrong. Thank you