 public func swizzleMethodInType(type: AnyClass, fromSelector: Selector, toSelector: Selector) {
 	precondition(fromSelector != toSelector)
 
-	let fromMethod = class_getInstanceMethod(type, fromSelector)
+	let fromMethod = class_getInstanceMethodIgnoringSupertypes(type, fromSelector)
 	guard fromMethod != nil else {
 		log("Selector '\(fromSelector)' was not swizzled with selector '\(toSelector)' since the former is not present in '\(type)'.")
 		return
 	}
 
-	let toMethod = class_getInstanceMethod(type, toSelector)
+	let toMethod = class_getInstanceMethodIgnoringSupertypes(type, toSelector)
 	guard toMethod != nil else {
 		log("Selector '\(fromSelector)' was not swizzled with selector '\(toSelector)' since the latter is not present in '\(type)'.")
 		return

}


public func redirectMethodInType(type: AnyClass, fromSelector: Selector, toSelector: Selector) {
	precondition(fromSelector != toSelector)

	let fromMethod = class_getInstanceMethod(type, fromSelector)
	guard fromMethod != nil else {
		log("Selector '\(fromSelector)' was not redirected to selector '\(toSelector)' since the former is not present in '\(type)'.")
		return
	}

	let toMethod = class_getInstanceMethod(type, toSelector)
	guard toMethod != nil else {
		log("Selector '\(fromSelector)' was not redirected to selector '\(toSelector)' since the latter is not present in '\(type)'.")
		return
	}

	let fromTypePointer = method_getTypeEncoding(fromMethod)
	let toTypePointer = method_getTypeEncoding(toMethod)
	guard fromTypePointer != nil && toTypePointer != nil, let fromType = String.fromCString(fromTypePointer), toType = String.fromCString(toTypePointer) else {
		log("Selector '\(fromSelector)' was not redirected to selector '\(toSelector)' since their type encodings could not be accessed.")
		return
	}
	guard fromType == toType else {
		log("Selector '\(fromSelector)' was not redirected to selector '\(toSelector)' since their type encodings don't match: '\(fromType)' -> '\(toType)'.")
		return
	}


	var random: Element = 0
	arc4random_buf(&random, sizeof(Element))
	return random
}


private func class_getInstanceMethodIgnoringSupertypes(clazz: AnyClass!, _ name: Selector) -> Method {
	let method = class_getInstanceMethod(clazz, name)

	if let superclass = class_getSuperclass(clazz) {
		let superclassMethod = class_getInstanceMethod(superclass, name)
		guard superclassMethod != method else {
			return nil
		}
	}

	return method
}


