Skip to content

Commit 5ead5c9

Browse files
committed
Fixing errorTitle and errorMessage variables
1 parent dc14350 commit 5ead5c9

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

Example/LoadingViewController/ViewController.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ class ViewController: LoadingViewController {
1919
delay(1.0) { [weak self] in
2020
self?.setVisibleScreen(.Loading)
2121
self?.delay(3, closure: { [weak self] in
22-
self?.errorTitle = "Lorem ipsum dolor sit amet, et nisl rebum viderer nam."
23-
self?.errorMessage = "Ne laudem expetendis intellegam nec. Vel eu veritus omnesque, ei dolorem oporteat eos, admodum praesent te vix. Vel albucius oportere euripidis ne. Eum in timeam persius, no labore persequeris per, ea vix adhuc postulant."
22+
let userInfo = [NSLocalizedDescriptionKey:NSLocalizedString("Operation was unsuccessful.", comment: ""), NSLocalizedFailureReasonErrorKey:NSLocalizedString("The operation timed out.", comment:""), NSLocalizedRecoverySuggestionErrorKey:NSLocalizedString("Have you tried turning it off and on again?", comment: "")]
23+
let error = NSError(domain: "some doman", code: 1000, userInfo: userInfo)
24+
self?.lastError = error
25+
2426
self?.errorIcon = UIImage(named: "doc_fail")
2527
self?.setVisibleScreen(.Failure)
2628
self?.delay(2, closure: {
@@ -39,7 +41,7 @@ class ViewController: LoadingViewController {
3941
}
4042

4143
override func loadingViewStyle() -> LoadingViewStyle {
42-
return .Multicolor
44+
return .Stroke
4345
}
4446
}
4547

LoadingViewController.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'LoadingViewController'
11-
s.version = '0.1.5'
11+
s.version = '0.1.6'
1212
s.summary = 'LoadingViewController is a component for changing controller views: content -> loading -> content or content -> loading -> error.'
1313

1414
# This description is used to generate tags and improve search results.

LoadingViewController/Classes/LoadingViewController.swift

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,29 @@ public class LoadingViewController: UIViewController {
4444

4545
@IBOutlet public var contentView: UIView!
4646

47+
public var lastError: NSError?
48+
4749
var visibleContentType: ContentType = .Undefined
4850
var activeView: UIView?
4951

5052
var animationQueue = Array<AnimationDict>()
5153
var currentAnimation: AnimationDict?
5254

53-
public var errorTitle: String = NSLocalizedString("Oops, something went wrong", comment: "")
54-
public var errorMessage: String?
55+
public var errorTitle: String {
56+
get {
57+
return lastError?.localizedDescription ?? NSLocalizedString("Oops, something went wrong", comment: "")
58+
}
59+
}
60+
public var errorMessage: String {
61+
get {
62+
return lastError?.localizedFailureReason ?? NSLocalizedString("Please try again later", comment: "")
63+
}
64+
}
5565
public var errorIcon: UIImage?
5666
public var errorAction: String?
5767

5868
var noDataAction: String?
59-
public var moDataMessage: String = NSLocalizedString("No data availabel", comment: "")
69+
public var noDataMessage: String = NSLocalizedString("No data availabel", comment: "")
6070

6171
var contentViewAllwaysAvailabel: Bool = false
6272

LoadingViewController/Classes/Views/ErrorViews/ErrorView.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class ErrorView: UIView {
4040
errorView.action = actionHandler
4141
return errorView
4242
}
43-
4443
}
4544

4645
func didSetTitle() {}

0 commit comments

Comments
 (0)