Commit 5913388b authored by Aral Balkan's avatar Aral Balkan

Updated the readme with the latest installation instructions and standard readme file structure.

parent f5231ebc
......@@ -4,11 +4,17 @@ Handle is an easy-to-use, expressive Swift micro-library for handling notificati
## Installation
Install via Carthage or include it in your project as a framework or simply drag the source into your project and compile it.
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
## Usage
The Handle demonstration apps do not have any dependencies, just open up the Delay.xcworkspace in Xcode and build and run the iOS and OS X demos.
See the [detailed installation instructions](#detailed-installation-instructions), below, for instructions on how to add Delay to your own apps.
## Getting started
For a demo, run the HandleDemo-iOS project.
Run the `./dev` script and play with the iOS and OS X demo apps.
## Usage
### Idiom: notification enums
......@@ -19,12 +25,12 @@ import Handle
public enum MyNotification:String
{
case AwesomeNotification
case AwesomeNotification
public static func named(notification: MyNotification) -> String
{
return notification.rawValue
}
public static func named(notification: MyNotification) -> String
{
return notification.rawValue
}
}
```
......@@ -45,18 +51,14 @@ import Handle
var notificationHandler:NotificationHandler?
// …
// Safely create a notification handler.
notificationHandler = notificationHandler ?? handle(MyNotification.named(.AwesomeNotification))
{
/* with */ notification in
/* with */ notification in
// Do something awesome.
// Do something awesome.
}
// …
// Destroy the handler when it is no longer needed.
destroyNotificationHandler(&notificationHandler)
```
......@@ -73,6 +75,39 @@ Read more about the library [in this blog post](https://ind.ie/labs/blog/handle)
Note that Handle is optimised for ease of authoring, beauty of interface and clarity of intent. I haven’t run into performance issues and hence haven’t felt the need to run any benchmarks at the moment but if you want maximum performance, using the NSNotificationCenter methods directly will give you shorter stack traces.
## Detailed installation instructions
### Carthage
1. Add the framework to your `Cartfile`. e.g.,
```git "git@source.ind.ie:project/handle.git" ~> 2.0```
2. [Follow the instructions on Carthage’s readme](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application).
### Manual
#### iOS
This requires hacking the Xcode project file but it’s still the most elegant way of doing things. If you want a better way, [dupe this radar for seamless support of fat frameworks in Xcode](http://openradar.appspot.com/radar?id=4951631992979456).
1. Build the framework target.
2. In Xcode, add the framework to the Embed Binaries
3. Edit the `project.pbxproj` (in the <your-project>.xcodeproj folder) file and replace the line that reads something like:
```A79882251C259F730043754A /* Handle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Handle.framework; path = "../../path/in/DerivedData/to/Handle.framework"; sourceTree = "<group>"; };```
With:
```A79882251C259F730043754A /* Handle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Handle.framework; path = "$(CONFIGURATION_BUILD_DIR)/Handle.framework"; sourceTree = "<group>"; };```
(In other words, you’re replacing the hardcoded path to the Delay.framework within your particular Derived Data folder with a generic one. This means that anyone else who checks out your project will get the correct framework.)
#### OS X
1. Just drag the framework into the Linked Frameworks and Binaries section of your project (under General).
(For an example of manually adding the framework, see the iOS and OS X demo apps that ship with this framework.)
## Credits
Copyright © Aral Balkan.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment