Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrtobolski committed Mar 22, 2017
1 parent fe5b76e commit 8109461
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,42 @@
[![License](https://img.shields.io/cocoapods/l/SwiftyInvocation.svg?style=flat)](http://cocoapods.org/pods/SwiftyInvocation)
[![Platform](https://img.shields.io/cocoapods/p/SwiftyInvocation.svg?style=flat)](http://cocoapods.org/pods/SwiftyInvocation)


Have you ever dreamed about using NSInvocation from Swift code?
You hate Apple for the NS_SWIFT_UNAVAILABLE macro?

Me neither.

But sometimes we just HAVE to use it. And here it is.

## Example

To run the example project, clone the repo, and run `pod install` from the Example directory first.
Check the unit tests.

```swift
let array: NSArray = ["1", "2", "3"]

let selector = #selector(NSArray.object(at:))
let methodSignature = NSArray.si_instanceMethodSignature(for: selector)
let invocation = SIInvocation(methodSignature: methodSignature)
invocation.target = array
invocation.selector = selector
var argument = 1
invocation.setArgument(&argument, at: 2)
invocation.retainArguments()

invocation.invoke()

var returnValue: Unmanaged<NSString>?
invocation.getReturnValue(&returnValue)

XCTAssertEqual(returnValue?.takeUnretainedValue(), "2")
```

## Requirements

Swift 3, Objective-C runtime

## Installation

SwiftyInvocation is available through [CocoaPods](http://cocoapods.org). To install
Expand All @@ -22,7 +52,7 @@ pod "SwiftyInvocation"

## Author

piotr-tobolski, piotr.tobolski@intive.com
Piotr Tobolski, piotr.tobolski@me.com

## License

Expand Down

0 comments on commit 8109461

Please sign in to comment.