Skip to content

Commit 684cce6

Browse files
authored
Merge pull request #4 from codecat15/multipart-form-data-format
adding an image extension for lazy loading
2 parents 65b6da5 + d1fac22 commit 684cce6

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

HttpUtility.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
86171D7C24C7330000D71D06 /* UIImageViewExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86171D7B24C7330000D71D06 /* UIImageViewExtension.swift */; };
1011
8656BC582483E3C60023549D /* EncodableExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8656BC572483E3C60023549D /* EncodableExtension.swift */; };
1112
8656BC5B2483E43D0023549D /* EncodableExtensionUnitTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8656BC5A2483E43D0023549D /* EncodableExtensionUnitTest.swift */; };
1213
8656BC5E2484313F0023549D /* HttpUtilityIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8656BC5D2484313F0023549D /* HttpUtilityIntegrationTests.swift */; };
@@ -28,6 +29,7 @@
2829
/* End PBXContainerItemProxy section */
2930

3031
/* Begin PBXFileReference section */
32+
86171D7B24C7330000D71D06 /* UIImageViewExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIImageViewExtension.swift; sourceTree = "<group>"; };
3133
8656BC572483E3C60023549D /* EncodableExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EncodableExtension.swift; sourceTree = "<group>"; };
3234
8656BC5A2483E43D0023549D /* EncodableExtensionUnitTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EncodableExtensionUnitTest.swift; sourceTree = "<group>"; };
3335
8656BC5D2484313F0023549D /* HttpUtilityIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HttpUtilityIntegrationTests.swift; sourceTree = "<group>"; };
@@ -64,6 +66,7 @@
6466
isa = PBXGroup;
6567
children = (
6668
8656BC572483E3C60023549D /* EncodableExtension.swift */,
69+
86171D7B24C7330000D71D06 /* UIImageViewExtension.swift */,
6770
);
6871
path = Extensions;
6972
sourceTree = "<group>";
@@ -245,6 +248,7 @@
245248
files = (
246249
86719EB124720E40002A2AB0 /* HttpUtility.swift in Sources */,
247250
8656BC582483E3C60023549D /* EncodableExtension.swift in Sources */,
251+
86171D7C24C7330000D71D06 /* UIImageViewExtension.swift in Sources */,
248252
);
249253
runOnlyForDeploymentPostprocessing = 0;
250254
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//
2+
// UIImageViewExtension.swift
3+
// HttpUtility
4+
//
5+
// Created by CodeCat15 on 7/21/20.
6+
// Copyright © 2020 CodeCat15. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import UIKit
11+
12+
extension UIImageView
13+
{
14+
func downloadImageFromUrl(urlString: String)
15+
{
16+
let url = URL(string: urlString)!
17+
18+
URLSession.shared.dataTask(with: url) { (data, response, error) in
19+
20+
if(data != nil)
21+
{
22+
DispatchQueue.main.async {
23+
self.image = UIImage(data: data!)
24+
}
25+
}
26+
}.resume()
27+
28+
}
29+
}

0 commit comments

Comments
 (0)