Skip to content

Commit

Permalink
First steps to a nicer readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mac-cain13 committed Jun 3, 2015
1 parent 57a9ef9 commit 948b237
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,40 @@
# R.swift
_Tool to get strong typed, autocompleted resources like images and segues in Swift_
_Tool to get strong typed, autocompleted resources like images, cells and segues in Swift_

## Why use this?

Normally you access your images, segues or storyboards based on strings, like `UIImage(names: "settings-icon")` or `performSegueWithIdentifier("openSettings")`. This is fragile since the compiler can't warn you about using the wrong identifier.

With R.swift we make sure you can use strong typed identifiers like `R.image.someIcon` or `R.segue.openSettings` to get your image or segue identifier, the `R`-struct will be automatically update on build. So it's never outdated and you will get compiler errors if you rename or delete a resource.
You currently type:
```swift
let icon = UIImage(names: "settings-icon")
let cell = dequeueReusableCellWithReuseIdentifier("textCell", forIndexPath: indexPath) as? TextCell
performSegueWithIdentifier("openSettings")
```

With R.swift it becomes:
```swift
let icon = R.images.settingsIcon
let cell = dequeueReusableCellWithReuseIdentifier(R.reuseIdentifier.textCell, forIndexPath: indexPath)
performSegueWithIdentifier(R.segue.openSettings)
```

It makes your code that uses resources:
- **Fully typed**, less casting and guessing what a method will return
- **Compiletime checked**, no more incorrect strings that make your app crash on runtime
- **Autocompleted**, never have to guess that image name again

## Usage

After installing R.swift into your project you can use the `R`-struct to access resources. If the struct is outdated just build and R.swift will correct any missing/changed/added resources. Below you find the different formats:
After installing R.swift into your project you can use the `R`-struct to access resources. If the struct is outdated just build and R.swift will correct any missing/changed/added resources.

R.swift currently supports:
- [X] Images
- [X] Segues
- [X] Storyboards
- [X] Nibs
- [X] Reusable cells
- [ ] Files in your bundle

Below you find the different formats:

Type | Format | Without R.swift | With R.swift
-----------------|------------------------------------------------------------|-------------------------------------------|-----------------------------
Expand Down

0 comments on commit 948b237

Please sign in to comment.