Skip to content

Commit 3ccd88a

Browse files
committed
Made the code compatible with Swift 4.2 by doing the following,
Replaced the method UIImagePNGRepresentation(self) with self.pngData() Replaced the method UIImageJPEGRepresentation(self, 1.0) with self.jpegData(compressionQuality: 1.0)
1 parent cafb434 commit 3ccd88a

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Cache.xcodeproj/project.pbxproj

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,7 @@
10271027
SDKROOT = appletvos;
10281028
SKIP_INSTALL = YES;
10291029
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
1030+
SWIFT_VERSION = 4.2;
10301031
TARGETED_DEVICE_FAMILY = 3;
10311032
TVOS_DEPLOYMENT_TARGET = 9.2;
10321033
};
@@ -1052,6 +1053,7 @@
10521053
PRODUCT_NAME = Cache;
10531054
SDKROOT = appletvos;
10541055
SKIP_INSTALL = YES;
1056+
SWIFT_VERSION = 4.2;
10551057
TARGETED_DEVICE_FAMILY = 3;
10561058
TVOS_DEPLOYMENT_TARGET = 9.2;
10571059
};
@@ -1143,6 +1145,7 @@
11431145
PRODUCT_NAME = Cache;
11441146
SDKROOT = macosx;
11451147
SKIP_INSTALL = YES;
1148+
SWIFT_VERSION = 4.2;
11461149
};
11471150
name = Debug;
11481151
};
@@ -1165,6 +1168,7 @@
11651168
PRODUCT_NAME = Cache;
11661169
SDKROOT = macosx;
11671170
SKIP_INSTALL = YES;
1171+
SWIFT_VERSION = 4.2;
11681172
};
11691173
name = Release;
11701174
};
@@ -1250,7 +1254,7 @@
12501254
ONLY_ACTIVE_ARCH = YES;
12511255
SDKROOT = iphoneos;
12521256
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
1253-
SWIFT_VERSION = 4.0;
1257+
SWIFT_VERSION = 4.2;
12541258
TARGETED_DEVICE_FAMILY = "1,2";
12551259
VERSIONING_SYSTEM = "apple-generic";
12561260
VERSION_INFO_PREFIX = "";
@@ -1302,7 +1306,7 @@
13021306
MTL_ENABLE_DEBUG_INFO = NO;
13031307
SDKROOT = iphoneos;
13041308
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
1305-
SWIFT_VERSION = 4.0;
1309+
SWIFT_VERSION = 4.2;
13061310
TARGETED_DEVICE_FAMILY = "1,2";
13071311
VALIDATE_PRODUCT = YES;
13081312
VERSIONING_SYSTEM = "apple-generic";
@@ -1326,6 +1330,7 @@
13261330
PRODUCT_BUNDLE_IDENTIFIER = no.hyper.Cache;
13271331
PRODUCT_NAME = Cache;
13281332
SKIP_INSTALL = YES;
1333+
SWIFT_VERSION = 4.2;
13291334
};
13301335
name = Debug;
13311336
};
@@ -1345,6 +1350,7 @@
13451350
PRODUCT_BUNDLE_IDENTIFIER = no.hyper.Cache;
13461351
PRODUCT_NAME = Cache;
13471352
SKIP_INSTALL = YES;
1353+
SWIFT_VERSION = 4.2;
13481354
};
13491355
name = Release;
13501356
};

Source/iOS/UIImage+Extensions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ extension UIImage {
2323
/// Convert to data
2424
func cache_toData() -> Data? {
2525
return hasAlpha
26-
? UIImagePNGRepresentation(self)
27-
: UIImageJPEGRepresentation(self, 1.0)
26+
? self.pngData()
27+
: self.jpegData(compressionQuality: 1.0)
2828
}
2929
}

0 commit comments

Comments
 (0)