Skip to content

Commit a2cdbf8

Browse files
authored
README: Edits and spelling/grammar fixes
1 parent 6600efc commit a2cdbf8

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

README.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ For more information, check out *["Type-safe identifiers in Swift"](https://www.
66

77
## Making types identifiable
88

9-
All you have to do to use Identity is to make a model conform to `Identifiable`, and giving it an `id` property, like this:
9+
All you have to do to use Identity is to make a model conform to `Identifiable`, and give it an `id` property, like this:
1010

1111
```swift
1212
struct User: Identifiable {
@@ -15,9 +15,11 @@ struct User: Identifiable {
1515
}
1616
```
1717

18+
And just like that, the above `User` identifier is now type-safe!
19+
1820
## Customizing the raw type
1921

20-
`Identifier` values are backed by strings by default, but that can be easily customized by giving an `Identifiable` type a `RawIdentifier`:
22+
`Identifier` values are backed by strings by default, but that can easily be customized by giving an `Identifiable` type a `RawIdentifier`:
2123

2224
```swift
2325
struct Article: Identifiable {
@@ -28,15 +30,17 @@ struct Article: Identifiable {
2830
}
2931
```
3032

33+
The above `Article` identifier is now backed by a `UUID` instead of a `String`.
34+
3135
## Conveniences built-in
3236

33-
Identity makes identifiers more type-safe, while still offering several conveniences to help reduce verbosity. For example, if an `Identifier` is backed by a raw value type that can be expressed by a `String` literal, so can the identifier:
37+
Even though Identity is focused on type safety, it still offers several conveniences to help reduce verbosity. For example, if an `Identifier` is backed by a raw value type that can be expressed by a `String` literal, so can the identifier:
3438

3539
```swift
3640
let user = User(id: "johnsundell", name: "John Sundell")
3741
```
3842

39-
The same is also true for identifiers that are backend by raw value type that can be expressed by `Int` literals:
43+
The same is also true for identifiers that are backend by a raw value type that can be expressed by `Int` literals:
4044

4145
```swift
4246
let tag = Tag(id: 7, name: "swift")
@@ -46,13 +50,13 @@ let tag = Tag(id: 7, name: "swift")
4650

4751
## Type safety
4852

49-
So how exactly does Identity make identifiers more type-safe? First, when using Identity, it no longer becomes possible to accidentally pass an identifier for one type to an API that accepts an identifier for another type. For example, this code won't compile:
53+
So how exactly does Identity make identifiers more type-safe? First, when using Identity, it no longer becomes possible to accidentally pass an identifier for one type to an API that accepts an identifier for another type. For example, this code won't compile when using Identity:
5054

5155
```swift
5256
articleManager.article(withID: user.id)
5357
```
5458

55-
The compiler will give us an error above, since we're trying to pass an `Identifier<User>` value to a method that accepts an `Identifier<Article>`, giving us much stronger type safety.
59+
The compiler will give us an error above, since we're trying to pass an `Identifier<User>` value to a method that accepts an `Identifier<Article>` - giving us much stronger type safety than when using plain values, like `String` or `Int`, as identifiers.
5660

5761
Identity also makes it impossible to accidentially declare `id` properties of the wrong type. So the following won't compile either:
5862

@@ -66,22 +70,16 @@ The reason the above code will fail to compile is because `Identifiable` require
6670

6771
## Installation
6872

69-
Since **Codextended** is implemented within a single file, the easiest way to use it is to simply drag and drop it into your Xcode project.
73+
Since Identity is implemented within a single file, the easiest way to use it is to simply drag and drop it into your Xcode project.
7074

71-
But if you wish to use a dependency manager, you can either use the [Swift Package Manager](https://github.com/apple/swift-package-manager) by declaring **Codextended** as a dependency in your `Package.swift` file:
75+
But if you wish to use a dependency manager, you can either use the [Swift Package Manager](https://github.com/apple/swift-package-manager) by declaring Identity as a dependency in your `Package.swift` file:
7276

7377
```swift
74-
.package(url: "https://github.com/JohnSundell/Codextended", from: "0.1.0")
78+
.package(url: "https://github.com/JohnSundell/Identity", from: "0.1.0")
7579
```
7680

7781
*For more information, see [the Swift Package Manager documentation](https://github.com/apple/swift-package-manager/tree/master/Documentation).*
7882

79-
You can also use [CocoaPods](https://cocoapods.org) by adding the following line to your `Podfile`:
80-
81-
```ruby
82-
pod "Codextended"
83-
```
84-
8583
## Contributions & support
8684

8785
Identity is developed completely in the open, and your contributions are more than welcome.

0 commit comments

Comments
 (0)