Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/electricbolt/corekit
Models, UI and other neat stuff for Swift apps
https://github.com/electricbolt/corekit
currency ios macos money string-manipulation swift swift-framework watchos
Last synced: 3 months ago
JSON representation
Models, UI and other neat stuff for Swift apps
- Host: GitHub
- URL: https://github.com/electricbolt/corekit
- Owner: electricbolt
- License: bsd-2-clause
- Created: 2019-04-15T08:14:52.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-08-11T08:18:51.000Z (6 months ago)
- Last Synced: 2024-11-13T04:35:29.265Z (3 months ago)
- Topics: currency, ios, macos, money, string-manipulation, swift, swift-framework, watchos
- Language: Swift
- Homepage:
- Size: 44.9 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## CoreKit
Models, UI and other neat stuff for Swift apps. Supports Swift 5.10, Xcode 15.4, iOS 13.0 and above.
### Models
#### Money & Currency
A Money is an struct that represents an amount and an associated currency. Amounts either represent a real value
(e.g. -$1927.10, ¥10, £1.56, 0.00kr.) or are unavailable (e.g. have no numerical value).> Swift example
```swift
let NZD = CurrencyManager.shared.get(code: "NZD")!
var m = Money(decimal: Decimal(40192.49), currency: NZD)
m += Money(float: 5.0, currency: NZD) // m is now 40197.49
let f = MoneyFormatter(currency: NZD)
let s = f.format(m) // s is now "$40,197.49"
```### Extensions
#### String
Extensions to Swift's String struct to provide easier and safer access to substrings (at the expense of performance). Easier - no String.Index manipulation is required, indexes are specified using Int's. Safer - all bounds checking is
performed before string manipulation, and therefore no possibility of generating an uncatchable fatal error can occur.> Swift example
```swift
let msg = "My dog has fleas"
let c: Character = msg[1]! // c is now "y"
var s: String = msg[4...] // s is now "og has fleas"
s = msg[7...35] // s is now "has fleas"
s = msg.removeSuffix("fleas") // s is now "my dog has "
```#### Data
Extensions to Swift's Data struct to provide Hex encoding and decoding. Coded for speed and between 6x to 34x faster than `map { String(format: "%02hhx", $0) }.joined()`
> Swift example
```swift
let d = Data(hexEncoded: "0fe3a9bc") // d is now 0x0f,0xe3,0xa9,0xbc
let s = d.hexEncodedString(options: .upperCase) // s is now "0FE3A9BC"
```