https://github.com/royalicing/burntfoundation
Pleasant Swift additions to Foundation
https://github.com/royalicing/burntfoundation
Last synced: about 2 months ago
JSON representation
Pleasant Swift additions to Foundation
- Host: GitHub
- URL: https://github.com/royalicing/burntfoundation
- Owner: RoyalIcing
- License: mit
- Created: 2015-05-16T09:15:06.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2018-10-31T10:31:16.000Z (over 7 years ago)
- Last Synced: 2025-01-18T23:44:09.296Z (over 1 year ago)
- Language: Swift
- Size: 35.2 KB
- Stars: 3
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BurntFoundation
Pleasant Swift additions to Foundation
## Examples
### User Defaults
```swift
enum ExampleIntChoice: Int, UserDefaultsChoiceRepresentable {
case One = 1
case Two = 2
case Three = 3
// The key that will be used with NSUserDefaults
static var identifier: String = "exampleInt"
static var defaultValue = ExampleIntChoice.One
}
```
Setting:
```swift
// Before:
ud.setInteger(3, forKey: "exampleInt")
// After:
ud.setChoice(ExampleIntChoice.Three)
```
Getting:
```swift
// Before:
let intValue = ud.integerForKey("exampleInt")
// After:
let intChoice = ud.choice(ExampleIntChoice)
```
### Notifications
```swift
class Example {
enum Notification: String {
case DidUpdate = "NotificationTestsDidUpdateNotification"
}
func update() {
// Do stuff...
// Post the notification
nc.postNotification(Example.Notification.DidUpdate, object: self)
}
}
let example = Example()
let notificationObserver = NotificationObserver(object: example)
notificationObserver.observe(.DidUpdate) { notification in
// Observe the notification
}
```
## Installation
To integrate BurntFoundation into your Xcode project using Carthage, specify it in your Cartfile:
```
github "BurntCaramel/BurntFoundation" >= 0.3
```