Merge pull request #5 from TouchInstinct/feature/swiftlint

fix SwiftLint warnings
This commit is contained in:
Nikolai Ashanin 2016-02-17 13:16:39 +03:00
commit 6dad910fff
16 changed files with 54 additions and 36 deletions

View File

@ -39,4 +39,4 @@ public class App {
return returnValue!
}
}
}

View File

@ -41,4 +41,4 @@ public class Log {
return startMessage
}
}
}

View File

@ -41,4 +41,4 @@ class LogFormatter: DDDispatchQueueLogFormatter {
return "\(level) \(dateAndTime) [\(logMessage.fileName):\(logMessage.line)]: \(logMessage.message)"
}
}
}

View File

@ -10,11 +10,14 @@ import UIKit
extension UIStoryboard {
/**
method for instanciating new UIViewController subclass from storyboard using storyboard identifier provided by StoryboardIdentifierProtocol protocol implementation
method for instanciating new UIViewController subclass from storyboard using storyboard identifier
provided by StoryboardIdentifierProtocol protocol implementation
- returns: UIViewController subclass instance
*/
public func instantiateViewController<T where T: UIViewController, T: StoryboardIdentifierProtocol>() -> T {
return instantiateViewControllerWithIdentifier(T.storyboardIdentifier()) as! T
}
}
}

View File

@ -10,25 +10,35 @@ import UIKit
extension UITableView {
/**
method which register UITableViewCell subclass for reusing in UITableView with reuse identifier provided by ReuseIdentifierProtocol protocol implementation and nib name provided by StaticNibNameProtocol protocol implementation
method which register UITableViewCell subclass for reusing in UITableView with reuse identifier
provided by ReuseIdentifierProtocol protocol implementation and nib name
provided by StaticNibNameProtocol protocol implementation
- parameter cellClass: UITableViewCell subclass which implements ReuseIdentifierProtocol and StaticNibNameProtocol
- see: ReuseIdentifierProtocol, StaticNibNameProtocol
*/
public func registerNib<T where T: ReuseIdentifierProtocol, T: UITableViewCell, T: StaticNibNameProtocol>(forCellClass cellClass: T.Type) {
public func registerNib<T where T: ReuseIdentifierProtocol, T: UITableViewCell, T: StaticNibNameProtocol>
(forCellClass cellClass: T.Type) {
self.registerNib(UINib(nibName: T.nibName()), forCellReuseIdentifier: T.reuseIdentifier())
}
/**
method which register UITableViewCell subclass for reusing in UITableView with reuse identifier provided by ReuseIdentifierProtocol protocol implementation and nib name provided by NibNameProtocol protocol implementation
method which register UITableViewCell subclass for reusing in UITableView with reuse identifier
provided by ReuseIdentifierProtocol protocol implementation and nib name
provided by NibNameProtocol protocol implementation
- parameter cellClass: UITableViewCell subclass which implements ReuseIdentifierProtocol and NibNameProtocol
- parameter interfaceIdiom: UIUserInterfaceIdiom value for NibNameProtocol
- see: ReuseIdentifierProtocol, NibNameProtocol
*/
public func registerNib<T where T: ReuseIdentifierProtocol, T: UITableViewCell, T: NibNameProtocol>(forCellClass cellClass: T.Type, forUserInterfaceIdiom interfaceIdiom: UIUserInterfaceIdiom) {
self.registerNib(UINib(nibName: T.nibName(forConfiguration: interfaceIdiom)), forCellReuseIdentifier: T.reuseIdentifier())
public func registerNib<T where T: ReuseIdentifierProtocol, T: UITableViewCell, T: NibNameProtocol>
(forCellClass cellClass: T.Type, forUserInterfaceIdiom interfaceIdiom: UIUserInterfaceIdiom) {
let nib = UINib(nibName: T.nibName(forConfiguration: interfaceIdiom))
self.registerNib(nib, forCellReuseIdentifier: T.reuseIdentifier())
}
}
}

View File

@ -10,7 +10,8 @@ import UIKit
extension UITableView {
/**
method for dequeueing reusable table view cell with specific class using reuse identifier provided by ReuseIdentifierProtocol implementation
method for dequeueing reusable table view cell with specific class using reuse identifier
provided by ReuseIdentifierProtocol implementation
- parameter indexPath: NSIndexPath object
@ -18,7 +19,10 @@ extension UITableView {
- see: ReuseIdentifierProtocol
*/
public func dequeueReusableCell<T where T: UITableViewCell, T: ReuseIdentifierProtocol>(forIndexPath indexPath: NSIndexPath) -> T {
public func dequeueReusableCell<T where T: UITableViewCell, T: ReuseIdentifierProtocol>
(forIndexPath indexPath: NSIndexPath) -> T {
return dequeueReusableCellWithIdentifier(T.reuseIdentifier(), forIndexPath: indexPath) as! T
}
}
}

View File

@ -8,13 +8,15 @@
import Foundation
extension UIView : StaticNibNameProtocol {
extension UIView: StaticNibNameProtocol {
/**
default implementation of StaticNibNameProtocol
- returns: class name string without dot (last class path component)
*/
public static func nibName() -> String {
return NSStringFromClass(self).componentsSeparatedByString(".").last!
}
}
}

View File

@ -9,13 +9,6 @@
import UIKit
extension UINib {
/**
convenience initialized for UINib class
- parameter name: name of the nib
- returns: UINib instance
*/
convenience public init(nibName name: String) {
self.init(nibName: name, bundle: nil)
}
@ -29,12 +22,15 @@ extension UIView {
- returns: UIView subclass instance
*/
public static func loadFromNib<T where T: NibNameProtocol, T: UIView>(forUserInterfaceIdiom interfaceIdiom: UIUserInterfaceIdiom) -> T {
public static func loadFromNib<T where T: NibNameProtocol, T: UIView>
(forUserInterfaceIdiom interfaceIdiom: UIUserInterfaceIdiom) -> T {
return loadFromNib(named: T.nibName(forConfiguration: interfaceIdiom))
}
/**
method which return UIView subclass instance loaded from nib using nib name provided by StaticNibNameProtocol implementation
method which return UIView subclass instance loaded from nib using nib name
provided by StaticNibNameProtocol implementation
- returns: UIView subclass instance
*/
@ -52,4 +48,5 @@ extension UIView {
public static func loadFromNib<T>(named nibName: String) -> T {
return UINib(nibName: nibName).instantiateWithOwner(nil, options: nil).first as! T
}
}
}

View File

@ -25,9 +25,11 @@ public protocol AbstractNibNameProtocol {
}
/**
* protocol which ensures that specific type can return nib name of view for specified UserInterfaceIdiom (iPhone, iPad, AppleTV)
* protocol which ensures that specific type can return nib name of view
for specified UserInterfaceIdiom (iPhone, iPad, AppleTV)
*/
public protocol NibNameProtocol : AbstractNibNameProtocol {
public protocol NibNameProtocol: AbstractNibNameProtocol {
/**
static method which returns nib name for specific UIUserInterfaceIdiom value
@ -36,4 +38,4 @@ public protocol NibNameProtocol : AbstractNibNameProtocol {
- returns: nib name string
*/
static func nibName(forConfiguration configuration: UIUserInterfaceIdiom) -> String
}
}

View File

@ -32,4 +32,4 @@ public protocol ReuseIdentifierProtocol: AbstractReuseIdentifierProtocol {
- returns: reuse identifier
*/
static func reuseIdentifier() -> String
}
}

View File

@ -18,4 +18,4 @@ public protocol StaticNibNameProtocol {
- returns: nib name string
*/
static func nibName() -> String
}
}

View File

@ -18,4 +18,4 @@ public protocol StaticViewHeightProtocol {
- returns: view height
*/
static func viewHeight() -> CGFloat
}
}

View File

@ -18,4 +18,4 @@ public protocol StoryboardIdentifierProtocol {
- returns: storyboard identifier string
*/
static func storyboardIdentifier() -> String
}
}

View File

@ -22,4 +22,4 @@ public protocol ViewHeightProtocol {
- returns: view height
*/
static func viewHeight(forViewModel viewModel: ViewModelType) -> CGFloat
}
}

View File

@ -20,4 +20,4 @@ protocol ViewModelBuilderProtocol {
- returns: view model object
*/
func buildViewModel() -> ViewModelType
}
}

View File

@ -22,4 +22,4 @@ public protocol AbstractViewModelProtocol {
- returns: nothing
*/
func setViewModel(viewModel: ViewModelType)
}
}