Skip to content

Commit 06da7f9

Browse files
authored
Merge pull request MengTo#214 from MengTo/swift3
ImageLoader fix
2 parents ce0b195 + 3a9227c commit 06da7f9

File tree

7 files changed

+31
-19
lines changed

7 files changed

+31
-19
lines changed

Spring/ImageLoader.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,19 @@ public class ImageLoader {
3737

3838
public func imageForUrl(urlString: String, completionHandler: @escaping(_ image: UIImage?, _ url: String) -> ()) {
3939
DispatchQueue.global(qos: DispatchQoS.QoSClass.background).async {
40-
let data: NSData? = self.cache.object(forKey: urlString as NSString)! as NSData
40+
var data: NSData?
41+
42+
if let dataCache = self.cache.object(forKey: urlString as NSString){
43+
data = (dataCache) as NSData
44+
45+
}else{
46+
if (URL(string: urlString) != nil)
47+
{
48+
data = NSData(contentsOf: URL(string: urlString)!)
49+
}else{
50+
return
51+
}
52+
}
4153

4254
if let goodData = data {
4355
let image = UIImage(data: goodData as Data)

Spring/SpringButton.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import UIKit
2424

25-
public class SpringButton: UIButton, Springable {
25+
open class SpringButton: UIButton, Springable {
2626
@IBInspectable public var autostart: Bool = false
2727
@IBInspectable public var autohide: Bool = false
2828
@IBInspectable public var animation: String = ""
@@ -43,12 +43,12 @@ public class SpringButton: UIButton, Springable {
4343

4444
lazy private var spring : Spring = Spring(self)
4545

46-
override public func awakeFromNib() {
46+
override open func awakeFromNib() {
4747
super.awakeFromNib()
4848
self.spring.customAwakeFromNib()
4949
}
5050

51-
public override func layoutSubviews() {
51+
open override func layoutSubviews() {
5252
super.layoutSubviews()
5353
spring.customLayoutSubviews()
5454
}

Spring/SpringImageView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import UIKit
2424

25-
public class SpringImageView: UIImageView, Springable {
25+
open class SpringImageView: UIImageView, Springable {
2626
@IBInspectable public var autostart: Bool = false
2727
@IBInspectable public var autohide: Bool = false
2828
@IBInspectable public var animation: String = ""
@@ -43,12 +43,12 @@ public class SpringImageView: UIImageView, Springable {
4343

4444
lazy private var spring : Spring = Spring(self)
4545

46-
override public func awakeFromNib() {
46+
override open func awakeFromNib() {
4747
super.awakeFromNib()
4848
self.spring.customAwakeFromNib()
4949
}
5050

51-
public override func layoutSubviews() {
51+
open override func layoutSubviews() {
5252
super.layoutSubviews()
5353
spring.customLayoutSubviews()
5454
}

Spring/SpringLabel.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import UIKit
2424

25-
public class SpringLabel: UILabel, Springable {
25+
open class SpringLabel: UILabel, Springable {
2626
@IBInspectable public var autostart: Bool = false
2727
@IBInspectable public var autohide: Bool = false
2828
@IBInspectable public var animation: String = ""
@@ -43,12 +43,12 @@ public class SpringLabel: UILabel, Springable {
4343

4444
lazy private var spring : Spring = Spring(self)
4545

46-
override public func awakeFromNib() {
46+
override open func awakeFromNib() {
4747
super.awakeFromNib()
4848
self.spring.customAwakeFromNib()
4949
}
5050

51-
public override func layoutSubviews() {
51+
open override func layoutSubviews() {
5252
super.layoutSubviews()
5353
spring.customLayoutSubviews()
5454
}

Spring/SpringTextField.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import UIKit
2424

25-
public class SpringTextField: UITextField, Springable {
25+
open class SpringTextField: UITextField, Springable {
2626
@IBInspectable public var autostart: Bool = false
2727
@IBInspectable public var autohide: Bool = false
2828
@IBInspectable public var animation: String = ""
@@ -43,12 +43,12 @@ public class SpringTextField: UITextField, Springable {
4343

4444
lazy private var spring : Spring = Spring(self)
4545

46-
override public func awakeFromNib() {
46+
override open func awakeFromNib() {
4747
super.awakeFromNib()
4848
self.spring.customAwakeFromNib()
4949
}
5050

51-
public override func layoutSubviews() {
51+
open override func layoutSubviews() {
5252
super.layoutSubviews()
5353
spring.customLayoutSubviews()
5454
}

Spring/SpringTextView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import UIKit
2424

25-
public class SpringTextView: UITextView, Springable {
25+
open class SpringTextView: UITextView, Springable {
2626
@IBInspectable public var autostart: Bool = false
2727
@IBInspectable public var autohide: Bool = false
2828
@IBInspectable public var animation: String = ""
@@ -43,12 +43,12 @@ public class SpringTextView: UITextView, Springable {
4343

4444
lazy private var spring : Spring = Spring(self)
4545

46-
override public func awakeFromNib() {
46+
override open func awakeFromNib() {
4747
super.awakeFromNib()
4848
self.spring.customAwakeFromNib()
4949
}
5050

51-
public override func layoutSubviews() {
51+
open override func layoutSubviews() {
5252
super.layoutSubviews()
5353
spring.customLayoutSubviews()
5454
}

Spring/SpringView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import UIKit
2424

25-
public class SpringView: UIView, Springable {
25+
open class SpringView: UIView, Springable {
2626
@IBInspectable public var autostart: Bool = false
2727
@IBInspectable public var autohide: Bool = false
2828
@IBInspectable public var animation: String = ""
@@ -43,12 +43,12 @@ public class SpringView: UIView, Springable {
4343

4444
lazy private var spring : Spring = Spring(self)
4545

46-
override public func awakeFromNib() {
46+
override open func awakeFromNib() {
4747
super.awakeFromNib()
4848
self.spring.customAwakeFromNib()
4949
}
5050

51-
public override func layoutSubviews() {
51+
open override func layoutSubviews() {
5252
super.layoutSubviews()
5353
spring.customLayoutSubviews()
5454
}

0 commit comments

Comments
 (0)