Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
DynamicObject.swift
import Foundation
@dynamicMemberLookup
class DynamicObject: NSObject {
subscript<T>(dynamicMember member: String) -> T? {
get {
return objc_getAssociatedObject(self, member) as? T
}
set {
objc_setAssociatedObject(self, member, newValue, .OBJC_ASSOCIATION_RETAIN)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.