Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save casademora/d0510802c62a46053b35e4503fbe7637 to your computer and use it in GitHub Desktop.
Save casademora/d0510802c62a46053b35e4503fbe7637 to your computer and use it in GitHub Desktop.
//: 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()
@sanjaybalaks
Copy link

Hi Casedemora,

The function doSomething() needs @obj dynamic keywords prefixed to be working correctly. Please correct me if wrong. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment