Merge pull request #94 from TouchInstinct/feature/refactoring

Little refactoring
This commit is contained in:
iON1k 2017-10-12 21:49:15 +03:00 committed by GitHub
commit cdef1fe5d8
28 changed files with 94 additions and 94 deletions

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "LeadKit"
s.version = "0.5.13"
s.version = "0.5.14"
s.summary = "iOS framework with a bunch of tools for rapid development"
s.homepage = "https://github.com/TouchInstinct/LeadKit"
s.license = "Apache License, Version 2.0"

View File

@ -39,8 +39,8 @@ public extension CGContext {
/// - cgImage: CGImage instance from which the parameters will be taken.
/// - fallbackColorSpace: Fallback color space if image doesn't have it.
/// - Returns: A new bitmap context, or NULL if a context could not be created.
public static func create(forCGImage cgImage: CGImage,
fallbackColorSpace: CGColorSpace = CGColorSpaceCreateDeviceRGB()) -> CGContext? {
static func create(forCGImage cgImage: CGImage,
fallbackColorSpace: CGColorSpace = CGColorSpaceCreateDeviceRGB()) -> CGContext? {
return create(width: cgImage.width,
height: cgImage.height,
@ -60,11 +60,11 @@ public extension CGContext {
/// - colorSpace: The color space to use for the bitmap context.
/// - bitsPerComponent: The number of bits to use for each component of a pixel in memory.
/// - Returns: A new bitmap context, or NULL if a context could not be created.
public static func create(width: Int,
height: Int,
bitmapInfo: CGBitmapInfo = .alphaBitmapInfo,
colorSpace: CGColorSpace = CGColorSpaceCreateDeviceRGB(),
bitsPerComponent: Int = 8) -> CGContext? {
static func create(width: Int,
height: Int,
bitmapInfo: CGBitmapInfo = .alphaBitmapInfo,
colorSpace: CGColorSpace = CGColorSpaceCreateDeviceRGB(),
bitsPerComponent: Int = 8) -> CGContext? {
return CGContext(data: nil,
width: width,

View File

@ -25,7 +25,7 @@ import CoreGraphics
public extension CGImage {
/// A Boolean value indicating whether the image data has an alpha channel.
public var hasAlpha: Bool {
var hasAlpha: Bool {
switch alphaInfo {
case .first, .last, .premultipliedFirst, .premultipliedLast:
return true

View File

@ -27,7 +27,7 @@ public extension CGImage {
/// Crop image to square from center.
///
/// - Returns: A new cropped image or nil if something goes wrong.
public func cropFromCenterToSquare() -> CGImage? {
func cropFromCenterToSquare() -> CGImage? {
let shortest = min(width, height)
let widthCropSize = width > shortest ? (width - shortest) : 0
@ -52,10 +52,10 @@ public extension CGImage {
/// - bottom: Bottom margin.
/// - right: Right margin.
/// - Returns: A new CGImage cropped with given paddings or nil if something goes wrong.
public func crop(top: CGFloat = 0,
left: CGFloat = 0,
bottom: CGFloat = 0,
right: CGFloat = 0) -> CGImage? {
func crop(top: CGFloat = 0,
left: CGFloat = 0,
bottom: CGFloat = 0,
right: CGFloat = 0) -> CGImage? {
let rect = CGRect(x: left,
y: top,

View File

@ -30,7 +30,7 @@ public extension CGSize {
/// - newSize: Requested new size.
/// - resizeMode: Resize mode to use.
/// - Returns: A new CGRect instance matching request parameters.
public func resizeRect(forNewSize newSize: CGSize, resizeMode: ResizeMode) -> CGRect {
func resizeRect(forNewSize newSize: CGSize, resizeMode: ResizeMode) -> CGRect {
let horizontalRatio = newSize.width / width
let verticalRatio = newSize.height / height

View File

@ -30,7 +30,7 @@ public extension Double {
- Normal: From 167.567 you will get 167.6
- Down: From 167.567 you will get 167.5
*/
public enum RoundingType {
enum RoundingType {
case normal
case down
}
@ -43,8 +43,8 @@ public extension Double {
- returns: rounded value
*/
public func roundValue(withPersicion persicion: UInt,
roundType: RoundingType = .normal) -> Double {
func roundValue(withPersicion persicion: UInt,
roundType: RoundingType = .normal) -> Double {
let divider = pow(10.0, Double(persicion))
switch roundType {

View File

@ -29,7 +29,7 @@ public extension NetworkService {
///
/// - Parameter url: An object adopting `URLConvertible`
/// - Returns: Observable of tuple containing (HTTPURLResponse, UIImage?)
public func rxLoadImage(url: String) -> Observable<(HTTPURLResponse, UIImage?)> {
func rxLoadImage(url: String) -> Observable<(HTTPURLResponse, UIImage?)> {
let request = RxAlamofire.requestData(.get, url, headers: [:])
return request

View File

@ -27,7 +27,7 @@ public extension StoryboardProtocol {
/**
- returns: default bundle for storyboard initialization
*/
public static var bundle: Bundle? {
static var bundle: Bundle? {
return Bundle.main
}

View File

@ -29,7 +29,7 @@ ViewControllerIdentifier: RawRepresentable, ViewControllerIdentifier.RawValue ==
/**
- returns: UIStoryboradInstance with StoryboardIdentifier name
*/
public static var uiStoryboard: UIStoryboard {
static var uiStoryboard: UIStoryboard {
return UIStoryboard(name: storyboardIdentifier.rawValue, bundle: bundle)
}
@ -40,7 +40,7 @@ ViewControllerIdentifier: RawRepresentable, ViewControllerIdentifier.RawValue ==
- returns: UIViewController instance
*/
public static func instantiateViewController(_ viewController: ViewControllerIdentifier) -> UIViewController {
static func instantiateViewController(_ viewController: ViewControllerIdentifier) -> UIViewController {
return uiStoryboard.instantiateViewController(withIdentifier: viewController.rawValue)
}

View File

@ -29,7 +29,7 @@ public extension String {
- returns: image
*/
public var image: UIImage? {
var image: UIImage? {
return UIImage(named: self)
}
@ -38,7 +38,7 @@ public extension String {
- returns: nil if string empty, self otherwise
*/
public var nilIfEmpty: String? {
var nilIfEmpty: String? {
return isEmpty ? nil : self
}

View File

@ -29,7 +29,7 @@ public extension String {
- returns: localized string
*/
public func localized() -> String {
func localized() -> String {
return NSLocalizedString(self, comment: "")
}

View File

@ -34,11 +34,11 @@ public struct StringSizeCalculationResult {
public extension StringSizeCalculationResult {
public var height: CGFloat { return size.height }
var height: CGFloat { return size.height }
public var width: CGFloat { return size.width }
var width: CGFloat { return size.width }
public var numberOfLines: UInt? {
var numberOfLines: UInt? {
if let lineHeight = fontLineHeight {
let lineHeightRounded = Double(lineHeight).roundValue(withPersicion: 2)
@ -65,9 +65,9 @@ public extension String {
- returns: string size calculation result
*/
public func size(withAttributes attributes: [String: AnyObject]?,
maxWidth: CGFloat = CGFloat.greatestFiniteMagnitude,
maxHeight: CGFloat = CGFloat.greatestFiniteMagnitude) -> StringSizeCalculationResult {
func size(withAttributes attributes: [String: AnyObject]?,
maxWidth: CGFloat = CGFloat.greatestFiniteMagnitude,
maxHeight: CGFloat = CGFloat.greatestFiniteMagnitude) -> StringSizeCalculationResult {
let size = self.boundingRect(with: CGSize(width: maxWidth, height: maxHeight),
options: [.usesLineFragmentOrigin, .usesFontLeading],

View File

@ -24,7 +24,7 @@ import UIKit
public extension Support where Base: UIScrollView {
public var refreshControl: UIRefreshControl? {
var refreshControl: UIRefreshControl? {
if #available(iOS 10.0, *) {
return base.refreshControl
} else {
@ -32,7 +32,7 @@ public extension Support where Base: UIScrollView {
}
}
public func setRefreshControl(_ newRefreshControl: UIRefreshControl?) {
func setRefreshControl(_ newRefreshControl: UIRefreshControl?) {
if #available(iOS 10.0, *) {
base.refreshControl = newRefreshControl
} else {

View File

@ -34,7 +34,7 @@ public extension TableDirector {
- returns: self
*/
@discardableResult
public func replace(section: TableSection, atIndex index: Int, reload: Bool = true) -> Self {
func replace(section: TableSection, atIndex index: Int, reload: Bool = true) -> Self {
if index < sections.count {
remove(sectionAt: index)
}
@ -54,7 +54,7 @@ public extension TableDirector {
- returns: self
*/
@discardableResult
public func reload(sectionAtIndex index: Int, with animation: UITableViewRowAnimation = .none) -> Self {
func reload(sectionAtIndex index: Int, with animation: UITableViewRowAnimation = .none) -> Self {
let action = { [tableView] in
guard let tableView = tableView else {
return
@ -82,7 +82,7 @@ public extension TableDirector {
- returns: self
*/
@discardableResult
public func replace(withSections sections: [TableSection]) -> Self {
func replace(withSections sections: [TableSection]) -> Self {
clear().append(sections: sections).reload()
return self
}
@ -95,7 +95,7 @@ public extension TableDirector {
- returns: self
*/
@discardableResult
public func replace(withSection section: TableSection) -> Self {
func replace(withSection section: TableSection) -> Self {
return replace(withSections: [section])
}
@ -107,7 +107,7 @@ public extension TableDirector {
- returns: self
*/
@discardableResult
public func replace(withRows rows: [Row]) -> Self {
func replace(withRows rows: [Row]) -> Self {
return replace(withSection: TableSection(rows: rows))
}

View File

@ -38,7 +38,7 @@ public extension TableRow where CellType.T: SeparatorCellViewModel {
public extension TableRow where CellType: SeparatorCell, CellType.T: SeparatorCellViewModel {
/// TableRow typed as SeparatorRowBox
public var separatorRowBox: SeparatorRowBox {
var separatorRowBox: SeparatorRowBox {
return SeparatorRowBox(tableRow: self)
}

View File

@ -33,7 +33,7 @@ public extension UICollectionView {
/// ReuseIdentifierProtocol and StaticNibNameProtocol
/// - bundle: The bundle in which to search for the nib file.
/// If you specify nil, this method looks for the nib file in the main bundle.
public func registerNib<T>(forCellClass cellClass: T.Type, bundle: Bundle? = nil)
func registerNib<T>(forCellClass cellClass: T.Type, bundle: Bundle? = nil)
where T: ReuseIdentifierProtocol, T: UICollectionViewCell, T: XibNameProtocol {
register(UINib(nibName: T.xibName, bundle: bundle), forCellWithReuseIdentifier: T.reuseIdentifier)

View File

@ -31,7 +31,7 @@ public extension UIColor {
- parameter hex3: Three-digit hexadecimal value.
- parameter alpha: 0.0 - 1.0. The default is 1.0.
*/
public convenience init(hex3: UInt16, alpha: CGFloat = 1) {
convenience init(hex3: UInt16, alpha: CGFloat = 1) {
let red = CGFloat((hex3 & 0xF00) >> 8) / 0xF
let green = CGFloat((hex3 & 0x0F0) >> 4) / 0xF
let blue = CGFloat((hex3 & 0x00F) >> 0) / 0xF
@ -44,7 +44,7 @@ public extension UIColor {
- parameter hex4: Four-digit hexadecimal value.
*/
public convenience init(hex4: UInt16) {
convenience init(hex4: UInt16) {
let red = CGFloat((hex4 & 0xF000) >> 12) / 0xF
let green = CGFloat((hex4 & 0x0F00) >> 8) / 0xF
let blue = CGFloat((hex4 & 0x00F0) >> 4) / 0xF
@ -59,7 +59,7 @@ public extension UIColor {
- parameter hex6: Six-digit hexadecimal value.
- parameter alpha: alpha: 0.0 - 1.0. The default is 1.0.
*/
public convenience init(hex6: UInt32, alpha: CGFloat = 1) {
convenience init(hex6: UInt32, alpha: CGFloat = 1) {
let red = CGFloat((hex6 & 0xFF0000) >> 16) / 0xFF
let green = CGFloat((hex6 & 0x00FF00) >> 8) / 0xFF
let blue = CGFloat((hex6 & 0x0000FF) >> 0) / 0xFF
@ -72,7 +72,7 @@ public extension UIColor {
- parameter hex8: Eight-digit hexadecimal value.
*/
public convenience init(hex8: UInt32) {
convenience init(hex8: UInt32) {
let red = CGFloat((hex8 & 0xFF000000) >> 24) / 0xFF
let green = CGFloat((hex8 & 0x00FF0000) >> 16) / 0xFF
let blue = CGFloat((hex8 & 0x0000FF00) >> 8) / 0xFF
@ -87,7 +87,7 @@ public extension UIColor {
- parameter hexString: hex string with red green and blue values (can have `#` sign)
- parameter alpha: alpha component used if not given in hexString
*/
public convenience init?(hexString: String, alpha: CGFloat = 1) {
convenience init?(hexString: String, alpha: CGFloat = 1) {
let hexStr: String
if hexString.hasPrefix("#") {

View File

@ -25,7 +25,7 @@ import UIKit
public extension UIDevice {
/// Returns true if the current device is simulator
public static var isSimulator: Bool {
static var isSimulator: Bool {
return ProcessInfo.processInfo.environment["SIMULATOR_DEVICE_NAME"] != nil
}

View File

@ -32,7 +32,7 @@ public extension UIImage {
/// - size: The size of an new image.
/// - scale: The scale of image.
/// - Returns: A new instanse of UIImage with given size and color.
public static func imageWith(color: UIColor, size: CGSize) -> UIImage {
static func imageWith(color: UIColor, size: CGSize) -> UIImage {
let width = Int(ceil(size.width))
let height = Int(ceil(size.height))
@ -45,7 +45,7 @@ public extension UIImage {
///
/// - Parameter fromView: The source view.
/// - Returns: A new instance of UIImage or nil if something goes wrong.
public static func imageFrom(view: UIView) -> UIImage {
static func imageFrom(view: UIView) -> UIImage {
let operation = CALayerDrawingOperation(layer: view.layer, size: view.bounds.size)
return operation.imageFromNewRenderer(scale: UIScreen.main.scale)
@ -55,7 +55,7 @@ public extension UIImage {
///
/// - Parameter color: Color to fill template image.
/// - Returns: A new UIImage rendered with given color.
public func renderTemplate(withColor color: UIColor) -> UIImage {
func renderTemplate(withColor color: UIColor) -> UIImage {
guard let image = cgImage else {
return self
}
@ -75,10 +75,10 @@ public extension UIImage {
/// - color: The color of the border.
/// - extendSize: Extend result image size and don't overlap source image by border.
/// - Returns: A new image with rounded corners.
public func roundCorners(cornerRadius: CGFloat,
borderWidth: CGFloat,
color: UIColor,
extendSize: Bool = false) -> UIImage {
func roundCorners(cornerRadius: CGFloat,
borderWidth: CGFloat,
color: UIColor,
extendSize: Bool = false) -> UIImage {
guard let image = cgImage else {
return self
@ -105,7 +105,7 @@ public extension UIImage {
/// Creates a new circle image.
///
/// - Returns: A new circled image.
public func roundCornersToCircle() -> UIImage {
func roundCornersToCircle() -> UIImage {
guard let image = cgImage else {
return self
}
@ -126,9 +126,9 @@ public extension UIImage {
/// - borderColor: The color of the border.
/// - extendSize: Extend result image size and don't overlap source image by border (default = false).
/// - Returns: A new image with rounded corners or nil if something goes wrong.
public func roundCornersToCircle(borderWidth: CGFloat,
borderColor: UIColor,
extendSize: Bool = false) -> UIImage {
func roundCornersToCircle(borderWidth: CGFloat,
borderColor: UIColor,
extendSize: Bool = false) -> UIImage {
guard let image = cgImage else {
return self
@ -162,9 +162,9 @@ public extension UIImage {
/// - cropToImageBounds: Should output image size match resized image size.
/// Note: If passed true with ResizeMode.scaleAspectFit content mode it will give the original image.
/// - Returns: A new image scaled to new size.
public func resize(newSize: CGSize,
contentMode: ResizeMode = .scaleToFill,
cropToImageBounds: Bool = false) -> UIImage {
func resize(newSize: CGSize,
contentMode: ResizeMode = .scaleToFill,
cropToImageBounds: Bool = false) -> UIImage {
guard let image = cgImage else {
return self
@ -182,7 +182,7 @@ public extension UIImage {
/// Adds an alpha channel if UIImage doesn't already have one.
///
/// - Returns: A copy of the given image, adding an alpha channel if it doesn't already have one.
public func applyAlpha() -> UIImage {
func applyAlpha() -> UIImage {
guard let image = cgImage, !image.hasAlpha else {
return self
}
@ -198,7 +198,7 @@ public extension UIImage {
///
/// - Parameter padding: The padding amount.
/// - Returns: A new padded image or nil if something goes wrong.
public func applyPadding(_ padding: CGFloat) -> UIImage {
func applyPadding(_ padding: CGFloat) -> UIImage {
guard let image = cgImage else {
return self
}

View File

@ -30,7 +30,7 @@ public extension Support where Base: UIImage {
/// - color: The color to fill
/// - size: The size of an new image.
/// - Returns: A new instanse of UIImage with given size and color or nil if something goes wrong.
public static func imageWith(color: UIColor, size: CGSize) -> Support<UIImage>? {
static func imageWith(color: UIColor, size: CGSize) -> Support<UIImage>? {
let width = Int(ceil(size.width))
let height = Int(ceil(size.height))
@ -43,7 +43,7 @@ public extension Support where Base: UIImage {
///
/// - Parameter fromView: The source view.
/// - Returns: A new instance of UIImage or nil if something goes wrong.
public static func imageFrom(view: UIView) -> Support<UIImage>? {
static func imageFrom(view: UIView) -> Support<UIImage>? {
let layerDrawingOperation = CALayerDrawingOperation(layer: view.layer, size: view.bounds.size)
return layerDrawingOperation.imageFromNewContext(scale: UIScreen.main.scale)?.support.flipY()
@ -53,7 +53,7 @@ public extension Support where Base: UIImage {
///
/// - Parameter color: Color to fill template image.
/// - Returns: A new UIImage rendered with given color or nil if something goes wrong.
public func renderTemplate(withColor color: UIColor) -> Support<UIImage>? {
func renderTemplate(withColor color: UIColor) -> Support<UIImage>? {
guard let image = base.cgImage else {
return Support<UIImage>(base)
}
@ -73,10 +73,10 @@ public extension Support where Base: UIImage {
/// - color: The color of the border.
/// - extendSize: Extend result image size and don't overlap source image by border.
/// - Returns: A new image with rounded corners or nil if something goes wrong.
public func roundCorners(cornerRadius: CGFloat,
borderWidth: CGFloat,
color: UIColor,
extendSize: Bool = false) -> Support<UIImage>? {
func roundCorners(cornerRadius: CGFloat,
borderWidth: CGFloat,
color: UIColor,
extendSize: Bool = false) -> Support<UIImage>? {
guard let image = base.cgImage else {
return Support<UIImage>(base)
@ -103,7 +103,7 @@ public extension Support where Base: UIImage {
/// Creates a new circle image.
///
/// - Returns: A new circled image or nil if something goes wrong.
public func roundCornersToCircle() -> Support<UIImage>? {
func roundCornersToCircle() -> Support<UIImage>? {
guard let image = base.cgImage else {
return Support<UIImage>(base)
}
@ -124,9 +124,9 @@ public extension Support where Base: UIImage {
/// - borderColor: The color of the border.
/// - extendSize: Extend result image size and don't overlap source image by border (default = false).
/// - Returns: A new image with rounded corners or nil if something goes wrong.
public func roundCornersToCircle(borderWidth: CGFloat,
borderColor: UIColor,
extendSize: Bool = false) -> Support<UIImage>? {
func roundCornersToCircle(borderWidth: CGFloat,
borderColor: UIColor,
extendSize: Bool = false) -> Support<UIImage>? {
guard let image = base.cgImage else {
return Support<UIImage>(base)
@ -160,9 +160,9 @@ public extension Support where Base: UIImage {
/// - cropToImageBounds: Should output image size match resized image size.
/// Note: If passed true with ResizeMode.scaleAspectFit content mode it will give the original image.
/// - Returns: A new image scaled to new size.
public func resize(newSize: CGSize,
contentMode: ResizeMode = .scaleToFill,
cropToImageBounds: Bool = false) -> Support<UIImage>? {
func resize(newSize: CGSize,
contentMode: ResizeMode = .scaleToFill,
cropToImageBounds: Bool = false) -> Support<UIImage>? {
guard let image = base.cgImage else {
return Support<UIImage>(base)
@ -180,7 +180,7 @@ public extension Support where Base: UIImage {
/// Adds an alpha channel if UIImage doesn't already have one.
///
/// - Returns: A copy of the given image, adding an alpha channel if it doesn't already have one.
public func applyAlpha() -> Support<UIImage>? {
func applyAlpha() -> Support<UIImage>? {
guard let image = base.cgImage, !image.hasAlpha else {
return Support<UIImage>(base)
}
@ -196,7 +196,7 @@ public extension Support where Base: UIImage {
///
/// - Parameter padding: The padding amount.
/// - Returns: A new padded image or nil if something goes wrong.
public func applyPadding(_ padding: CGFloat) -> Support<UIImage>? {
func applyPadding(_ padding: CGFloat) -> Support<UIImage>? {
guard let image = base.cgImage else {
return Support<UIImage>(base)
}

View File

@ -30,7 +30,7 @@ public extension UIView {
/// - Parameter bundle: The bundle in which to search for the nib file.
/// If you specify nil, this method looks for the nib file in the main bundle.
/// - Returns: UIView or UIView subclass instance
public static func loadFromNib<T>(bundle: Bundle? = nil) -> T where T: XibNameProtocol, T: UIView {
static func loadFromNib<T>(bundle: Bundle? = nil) -> T where T: XibNameProtocol, T: UIView {
return loadFromNib(named: T.xibName, bundle: bundle)
}
@ -42,7 +42,7 @@ public extension UIView {
/// If you specify nil, this method looks for the nib file in the main bundle.
/// - owner: current owner
/// - Returns: UIView or UIView subclass instance
public static func loadFromNib<T>(named nibName: String, bundle: Bundle? = nil, owner: UIView? = nil) -> T {
static func loadFromNib<T>(named nibName: String, bundle: Bundle? = nil, owner: UIView? = nil) -> T {
let nib = UINib(nibName: nibName, bundle: bundle)
guard let nibView = nib.instantiate(withOwner: owner, options: nil).first as? T else {

View File

@ -31,7 +31,7 @@ public extension UIView {
- parameter repeatCount: How many times the spin should be done. If not provided, the view will spin forever.
- parameter clockwise: Direction of the rotation. Default is clockwise (true).
*/
public func startZRotation(duration: CFTimeInterval = 1, repeatCount: Float = Float.infinity, clockwise: Bool = true) {
func startZRotation(duration: CFTimeInterval = 1, repeatCount: Float = Float.infinity, clockwise: Bool = true) {
let animation = CABasicAnimation.zRotationAnimationWith(duration: duration,
repeatCount: repeatCount,
clockwise: clockwise)
@ -39,7 +39,7 @@ public extension UIView {
}
/// Stop rotating the view around Z axis.
public func stopZRotation() {
func stopZRotation() {
layer.removeAnimation(forKey: CABasicAnimation.rotationKeyPath)
}

View File

@ -25,7 +25,7 @@ import UIKit
public extension UIViewController {
/// Return top visible controller even if we have inner UI(Navigation/TabBar)Controller's inside
public var topVisibleViewController: UIViewController {
var topVisibleViewController: UIViewController {
switch self {
case let navController as UINavigationController:
return navController.visibleViewController?.topVisibleViewController ?? navController

View File

@ -32,7 +32,7 @@ public extension UIWindow {
/// Method changes root controller in window.
///
/// - Parameter controller: New root controller.
public func changeRootController(controller: UIViewController) {
func changeRootController(controller: UIViewController) {
animateRootViewControllerChanging(controller: controller)
rootViewController?.dismiss(animated: false, completion: nil)

View File

@ -56,7 +56,7 @@ public extension UserDefaults {
///
/// - returns: The object with specified type associated with the specified key,
/// or throw exception if the key was not found.
public func object<T>(forKey key: String) throws -> T where T: ImmutableMappable {
func object<T>(forKey key: String) throws -> T where T: ImmutableMappable {
let jsonObject = try storedValue(forKey: key) as JSONObject
do {
@ -74,7 +74,7 @@ public extension UserDefaults {
///
/// - returns: The array of objects with specified type associated with the specified key,
/// or throw exception if the key was not found.
public func objects<T>(forKey key: String) throws -> [T] where T: ImmutableMappable {
func objects<T>(forKey key: String) throws -> [T] where T: ImmutableMappable {
let jsonArray = try storedValue(forKey: key) as [JSONObject]
do {
@ -92,7 +92,7 @@ public extension UserDefaults {
///
/// - returns: The object with specified type associated with the specified key, or passed default value
/// if there is no such value for specified key or if error occurred during mapping.
public func object<T>(forKey key: String, defaultValue: T) -> T where T: ImmutableMappable {
func object<T>(forKey key: String, defaultValue: T) -> T where T: ImmutableMappable {
return (try? object(forKey: key)) ?? defaultValue
}
@ -104,7 +104,7 @@ public extension UserDefaults {
///
/// - returns: The array of objects with specified type associated with the specified key, or passed default value
/// if there is no such value for specified key or if error occurred during mapping.
public func objects<T>(forKey key: String, defaultValue: [T]) -> [T] where T: ImmutableMappable {
func objects<T>(forKey key: String, defaultValue: [T]) -> [T] where T: ImmutableMappable {
return (try? objects(forKey: key)) ?? defaultValue
}
@ -113,7 +113,7 @@ public extension UserDefaults {
/// - Parameters:
/// - model: The object with specified type to store or nil to remove it from the defaults database.
/// - key: The key with which to associate with the value.
public func set<T>(model: T?, forKey key: String) where T: ImmutableMappable {
func set<T>(model: T?, forKey key: String) where T: ImmutableMappable {
if let model = model {
set(model.toJSON(), forKey: key)
} else {
@ -126,7 +126,7 @@ public extension UserDefaults {
/// - Parameters:
/// - models: The array of object with specified type to store or nil to remove it from the defaults database.
/// - key: The key with which to associate with the value.
public func set<T, S>(models: S?, forKey key: String) where T: ImmutableMappable, S: Sequence, S.Iterator.Element == T {
func set<T, S>(models: S?, forKey key: String) where T: ImmutableMappable, S: Sequence, S.Iterator.Element == T {
if let models = models {
set(models.map { $0.toJSON() }, forKey: key)
} else {

View File

@ -29,7 +29,7 @@ public protocol LoadingIndicatorHolder: class {
}
public extension LoadingIndicatorHolder where Self: UIView {
public var indicatorOwner: UIView {
var indicatorOwner: UIView {
return self
}
}

View File

@ -53,7 +53,7 @@ public protocol StoryboardProtocol {
public extension StoryboardProtocol {
public static func instantiate<T: UIViewController>(_ identificator: Self.ViewControllerIdentifier) -> T {
static func instantiate<T: UIViewController>(_ identificator: Self.ViewControllerIdentifier) -> T {
guard let controller = instantiateViewController(identificator) as? T else {
assertionFailure("\(T.self) not created")
return T()

View File

@ -63,7 +63,7 @@ public protocol SupportCompatible {
public extension SupportCompatible {
/// Support extensions.
public static var support: Support<Self>.Type {
static var support: Support<Self>.Type {
get {
return Support<Self>.self
}
@ -73,7 +73,7 @@ public extension SupportCompatible {
}
/// Support extensions.
public var support: Support<Self> {
var support: Support<Self> {
get {
return Support(self)
}