Skip to content

Instantly share code, notes, and snippets.

@DevAndArtist
Last active January 26, 2017 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DevAndArtist/0addb0f72b1ee0124064a96e960f2f4a to your computer and use it in GitHub Desktop.
Save DevAndArtist/0addb0f72b1ee0124064a96e960f2f4a to your computer and use it in GitHub Desktop.
/// An opaque type that represents a method in a class definition.
public struct Method {
public struct Description {
/**< The name (selector) of the method */
public var selector: Selector
/**< The types of the method arguments */
public var types: UnsafeMutablePointer<Int8>
public init()
public init(name: Selector, types: UnsafeMutablePointer<Int8>)
}
/**
* Returns the name (selector) of a method.
*
* @return A pointer of type SEL.
*
* @note To get the method name as a C string, call \c sel_getName(method.selector).
*/
@available(iOS 2.0, *)
public var selector: Selector { get }
/**
* Returns or sets the implementation of a method.
*
* @return A function pointer of type IMP.
*/
@available(iOS 2.0, *)
public var implementation: IMP { get set }
/**
* Returns a string describing a method's parameter and return types.
*
* @return A C string. The string may be \c NULL.
*/
@available(iOS 2.0, *)
public var typeEncoding: UnsafePointer<Int8> { get }
/**
* Returns the number of arguments accepted by a method.
*
* @return An integer containing the number of arguments accepted by the given method.
*/
@available(iOS 2.0, *)
public var numberOfArguments: UInt32 { get }
/**
* Returns a string describing a method's return type.
*
* @return A C string describing the return type. You must free the string with \c free().
*/
@available(iOS 2.0, *)
public var copyReturnType: UnsafeMutablePointer<Int8> { get }
/**
* Returns a string describing a single parameter type of a method.
*
* @param index The index of the parameter to inspect.
*
* @return A C string describing the type of the parameter at index \e index, or \c NULL
* if method has no parameter index \e index. You must free the string with \c free().
*/
@available(iOS 2.0, *)
public func copyArgumentType(at index: UInt32) -> UnsafeMutablePointer<Int8>
/**
* Returns a string describing a method's return type.
*/
@available(iOS 2.0, *)
public var returnType: String { get }
/**
* Returns a string describing a single parameter type of a method.
*
* @param index The index of the parameter you want to inquire about.
*/
@available(iOS 2.0, *)
public func argumentType(at index: UInt32) -> String?
@available(iOS 2.0, *)
public var description: UnsafeMutablePointer<Description> { get }
/**
* Exchanges the implementations of two methods.
*
* @param other Method to exchange with the current method.
*/
@available(iOS 2.0, *)
public func exchangeImplementation(with other: Method)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment