Sugar
Sugar is a sweetener for your Cocoa implementations.
iOS
Application
Gain easy access to main bundle information.
Screen
Get the actual pixel information of the device screen.
Simulator
To easily exclude operations from when you as a developer runs the application in the simulator,
not subscribing to push notification or running analytics operations etc.
Keyboard Observer
Observe keyboard showing and hiding events, and handle it
Currently support
- BasicKeyboardHandler: basic UIView animation
- InsetKeyboardHandler: animate UIScrollView insets
- ConstraintKeyboardHandler: animate bottom layout constraint
- CustomKeyboardHandler: custom handling
iOS Extensions
UIView
.optimize()
UIImage
+Rendering mode
Shared
SequenceType
Dates
Compare
Construct
Frame
Grand Central Dispatch
Easy dispatching with grand central dispatch.
Support all the regular global queues: Main
, Interactive
, Initiated
, Utility
, Background
.
And .Custom()
for your own dispatch queues.
Localization
Swift access (pun intended) to NSLocalizedString
, you will get more valid auto completion
with this one, we promise.
Once
Operators
The ?=
only assigns values if the right is not nil.
Range
Regex
Shared Extensions
+Queueable
Make your own processing queue with ease, just make your object conform the Queueable
.
URLStringConvertible
Highly inspired by / borrowed from Alamofire's implementation of URLStringConvertible.
Core Foundation
Just some extra sugar on top of String
for getting the length, truncating, trimming or splitting a String
.
isPresent
is the opposite of isEmpty
.
contains
and be used to check if a string contains a word or pharse.
Swizzler
Everyday we are swizzling, this use to be mundane, now it just Swiftling, we mean, super fast.
Then
let UIView().then {
$0.backgroundColor = UIColor.blackColor()
}
This implementation is brought to you by @devxoul by his awesome Then repository.
Type Alias
UITesting
if UITesting.isRunning {
// tests are running
} else {
// everything is fine, move along
}
To easily include or exclude operations for when you are running UI tests.
UnitTesting
if UnitTesting.isRunning {
// running test
}
func testPerformance() {
let measurement = measure {
// run operation
}
}
Check if you are running UniTests and to measure performance.
Installation
Sugar is available through CocoaPods. To install
it, simply add the following line to your Podfile:
Sugar is also available through Carthage.
To install just write into your Cartfile:
Sugar is also available through Swift Package Manager.
- iOS: Open Xcode, File->Swift Packages, search input https://github.com/hyperoslo/Sugar.git, and then select Version Up to Next Major 5.0.1 < .
- Or add dependencies in your
Package.swift
:
Author
Hyper Interaktiv AS, ios@hyper.no
License
Sugar is available under the MIT license. See the LICENSE file for more info.