Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/miottid/swifthelpers
A Swift library of various helpers
https://github.com/miottid/swifthelpers
Last synced: 5 days ago
JSON representation
A Swift library of various helpers
- Host: GitHub
- URL: https://github.com/miottid/swifthelpers
- Owner: miottid
- License: mit
- Created: 2015-01-14T10:47:37.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2021-09-14T15:04:02.000Z (about 3 years ago)
- Last Synced: 2023-08-09T21:48:19.863Z (over 1 year ago)
- Language: Swift
- Homepage:
- Size: 323 KB
- Stars: 6
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Features
- [x] Date extension (like ActiveRecord)
- [x] DateFormatter convenience
- [x] Array.each
- [x] Int / NSTimeInterval `.every`, a block based for NSTimer
- [x] UIColor helpers
- [x] UIView helpers
- [x] Various helpers
- [x] Easy localization## Requirements
- iOS 7.0+ / Mac OS X 10.9+
- Xcode 6.1## Installation
```
pod 'SwiftHelpers'
```### Available subspecs
- `pod 'SwiftHelpers/Basic'` contains localization helpers, as well as IBInspectable localization attributes
- `pod 'SwiftHelpers/Core'` contains core types helpers (comparison, array extensions, timers, ...)
- `pod 'SwiftHelpers/CoreData'` contains CoreData helpers
- `pod 'SwiftHelpers/UI'` contains controllers and views
- `pod 'SwiftHelpers/DateTime'` contains Date related helpers and formatters
- `pod 'SwiftHelpers/Misc'` contains miscellanous helpers (credit card, keyboard, notifications...)> For application targets that do not support embedded frameworks, such as iOS 7, SwiftHelpers can be integrated by including the `SwiftHelpers` folder directly, wrapping the top-level types in `struct SwiftHelpers` to simulate a namespace. Yes, this sucks.
_Due to the current lack of [proper infrastructure](http://cocoapods.org) for Swift dependency management, using SwiftHelpers in your project requires the following steps:_
1. Add SwiftHelpers as a [submodule](http://git-scm.com/docs/git-submodule) by opening the Terminal, `cd`-ing into your top-level project directory, and entering the command `git submodule add https://github.com/dmiotti/SwiftHelpers`
2. Open the `SwiftHelpers` folder, and drag `SwiftHelpers.xcodeproj` into the file navigator of your app project.
3. In Xcode, navigate to the target configuration window by clicking on the blue project icon, and selecting the application target under the "Targets" heading in the sidebar.
4. Ensure that the deployment target of SwiftHelpers.framework matches that of the application target.
5. In the tab bar at the top of that window, open the "Build Phases" panel.
6. Expand the "Target Dependencies" group, and add `SwiftHelpers.framework`.
7. Click on the `+` button at the top left of the panel and select "New Copy Files Phase". Rename this new phase to "Copy Frameworks", set the "Destination" to "Frameworks", and add `SwiftHelpers.framework`.---
## Usage
_Everything is documented, check it out_
### Common Init Views
#### UIView
You can subclass `SHCommonInitView` and override `commonInit()`. This function will be called not matter if the view was created programmaticaly like `SHCommonInitView()` or in Storyboard.
The same apply with `SHCommonInitTableViewCell` and `SHCommonInitCollectionViewCell`.### NSDate comparison operators
```swift
import SwiftHelperslet date1 = NSDate()
let date2 = date1.dateByAddingTimeInterval(10) // 10 seconds laterif date1 > date2 {
println("date1 > date2")
}if date1 < date2 {
println("date1 < date2")
}if date1 <= date2 {
println("date1 <= date2")
}
....
```## NSDate like ActiveRecord
```swift
import SwiftHelperslet yesterday = 1.day.ago
let firstJanuary = 1.january
let inTwoDays = NSDate() + 2.days
let bornDate = 16.october.of(1986)
let nextBirthDay = bornDate.next
let tenSecondsLater = 10.seconds.fromNow
let laterOn = NSDate() + 1.month + 1.day + 10.secondseach([1, 5]) { item in
let number = item as Int
...
}10.each { number in
let nextNumber = number + 3
}
```## Various helpers
```swift
let dateFormatter = NSDateFormatter(dateFormat: "d EEEE MMMM yyyy")
```## Tests
You can run Unit Tests using Xcode default behavior.
## Contributors
- David Miotti ([email protected])
- Guillaume Bellue ([email protected])
- Maxime de Chalendar ([email protected])