diff --git a/Cartfile.private b/Cartfile.private deleted file mode 100644 index e67aa45..0000000 --- a/Cartfile.private +++ /dev/null @@ -1 +0,0 @@ -github "thoughtbot/Runes" >= 3.0.0 diff --git a/Cartfile.resolved b/Cartfile.resolved deleted file mode 100644 index bae0e21..0000000 --- a/Cartfile.resolved +++ /dev/null @@ -1 +0,0 @@ -github "thoughtbot/Runes" "v3.1.0" diff --git a/Carthage/Checkouts/Runes b/Carthage/Checkouts/Runes deleted file mode 160000 index 17ff8dc..0000000 --- a/Carthage/Checkouts/Runes +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 17ff8dcc1331ed1f2cb949d6af194844a180021c diff --git a/Gifu.xcodeproj/project.pbxproj b/Gifu.xcodeproj/project.pbxproj index cb65ab7..6efe86a 100644 --- a/Gifu.xcodeproj/project.pbxproj +++ b/Gifu.xcodeproj/project.pbxproj @@ -9,7 +9,6 @@ /* Begin PBXBuildFile section */ 0036ABB71BBD1D0B00C6CC3D /* mugen.gif in Resources */ = {isa = PBXBuildFile; fileRef = 0036ABB61BBD1D0B00C6CC3D /* mugen.gif */; }; 0036ABB91BBD1D1400C6CC3D /* nailed.gif in Resources */ = {isa = PBXBuildFile; fileRef = 0036ABB81BBD1D1400C6CC3D /* nailed.gif */; }; - 004529921BD82209006493BF /* Runes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 004529911BD82209006493BF /* Runes.swift */; }; 005656ED1A6F14D6008A0ED1 /* Animator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 005656EC1A6F14D6008A0ED1 /* Animator.swift */; }; 005656EF1A6F1C26008A0ED1 /* AnimatableImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 005656EE1A6F1C26008A0ED1 /* AnimatableImageView.swift */; }; 007E08441BD95E6200883D0C /* ArrayExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 007E08431BD95E6200883D0C /* ArrayExtension.swift */; }; @@ -19,7 +18,6 @@ 00B8C75F1A364DCE00C188E7 /* ImageSourceHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00B8C75C1A364DCE00C188E7 /* ImageSourceHelpers.swift */; }; 00B8C7961A3650EE00C188E7 /* Gifu.h in Headers */ = {isa = PBXBuildFile; fileRef = 00B8C7951A3650EE00C188E7 /* Gifu.h */; settings = {ATTRIBUTES = (Public, ); }; }; EAF49C7F1A3A4DE000B395DF /* UIImageExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF49C7E1A3A4DE000B395DF /* UIImageExtension.swift */; }; - EAF49C811A3A4FAA00B395DF /* FunctionalHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF49C801A3A4FAA00B395DF /* FunctionalHelpers.swift */; }; EAF49CB11A3B6EEB00B395DF /* AnimatedFrame.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF49CB01A3B6EEB00B395DF /* AnimatedFrame.swift */; }; /* End PBXBuildFile section */ @@ -36,7 +34,6 @@ /* Begin PBXFileReference section */ 0036ABB61BBD1D0B00C6CC3D /* mugen.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; name = mugen.gif; path = Demo/demo/Images.xcassets/mugen.dataset/mugen.gif; sourceTree = SOURCE_ROOT; }; 0036ABB81BBD1D1400C6CC3D /* nailed.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; name = nailed.gif; path = Demo/demo/Images.xcassets/nailed.dataset/nailed.gif; sourceTree = SOURCE_ROOT; }; - 004529911BD82209006493BF /* Runes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Runes.swift; path = Carthage/Checkouts/Runes/Source/Runes.swift; sourceTree = SOURCE_ROOT; }; 005656EC1A6F14D6008A0ED1 /* Animator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Animator.swift; sourceTree = ""; }; 005656EE1A6F1C26008A0ED1 /* AnimatableImageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnimatableImageView.swift; sourceTree = ""; }; 007E08431BD95E6200883D0C /* ArrayExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ArrayExtension.swift; sourceTree = ""; }; @@ -49,7 +46,6 @@ 00B8C75C1A364DCE00C188E7 /* ImageSourceHelpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageSourceHelpers.swift; sourceTree = ""; }; 00B8C7951A3650EE00C188E7 /* Gifu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Gifu.h; sourceTree = ""; }; EAF49C7E1A3A4DE000B395DF /* UIImageExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIImageExtension.swift; sourceTree = ""; }; - EAF49C801A3A4FAA00B395DF /* FunctionalHelpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FunctionalHelpers.swift; sourceTree = ""; }; EAF49CB01A3B6EEB00B395DF /* AnimatedFrame.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnimatedFrame.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -94,8 +90,6 @@ 007E08411BD95C0200883D0C /* Helpers */ = { isa = PBXGroup; children = ( - 004529911BD82209006493BF /* Runes.swift */, - EAF49C801A3A4FAA00B395DF /* FunctionalHelpers.swift */, 00B8C75C1A364DCE00C188E7 /* ImageSourceHelpers.swift */, ); name = Helpers; @@ -299,10 +293,8 @@ 005656EF1A6F1C26008A0ED1 /* AnimatableImageView.swift in Sources */, 005656ED1A6F14D6008A0ED1 /* Animator.swift in Sources */, 009BD1441BBC93C800FC982B /* CGSizeExtension.swift in Sources */, - 004529921BD82209006493BF /* Runes.swift in Sources */, EAF49CB11A3B6EEB00B395DF /* AnimatedFrame.swift in Sources */, 00B8C75F1A364DCE00C188E7 /* ImageSourceHelpers.swift in Sources */, - EAF49C811A3A4FAA00B395DF /* FunctionalHelpers.swift in Sources */, 007E08441BD95E6200883D0C /* ArrayExtension.swift in Sources */, EAF49C7F1A3A4DE000B395DF /* UIImageExtension.swift in Sources */, ); diff --git a/Source/AnimatableImageView.swift b/Source/AnimatableImageView.swift index 5db3ee3..4bfae8a 100644 --- a/Source/AnimatableImageView.swift +++ b/Source/AnimatableImageView.swift @@ -52,7 +52,8 @@ public class AnimatableImageView: UIImageView { /// - parameter imageName: The name of the GIF file. The method looks for the file in the app bundle. public func prepareForAnimation(imageNamed imageName: String) { let imagePath = NSBundle.mainBundle().bundleURL.URLByAppendingPathComponent(imageName) - prepareForAnimation <^> NSData(contentsOfURL: imagePath) + guard let data = NSData(contentsOfURL: imagePath) else { return } + prepareForAnimation(imageData: data) } /// Prepares the frames using raw GIF image data, without starting the animation. diff --git a/Source/Animator.swift b/Source/Animator.swift index 37ce26d..452cd17 100644 --- a/Source/Animator.swift +++ b/Source/Animator.swift @@ -55,7 +55,7 @@ class Animator { frameCount = Int(CGImageSourceGetCount(imageSource)) let framesToProcess = min(frameCount, maxFrameCount) animatedFrames.reserveCapacity(framesToProcess) - animatedFrames = (0.. (@noescape f: T -> U, a: T?) -> U? { - return a.map(f) -} -func <*> (f: (T -> U)?, a: T?) -> U? { - return a.apply(f) -} - -func >>- (a: T?, @noescape f: T -> U?) -> U? { - return a.flatMap(f) -} - -extension Optional { - func apply(f: (Wrapped -> U)?) -> U? { - return f.flatMap { self.map($0) } - } -} - -func pure(a: T) -> [T] { - return [a] -} diff --git a/Source/ImageSourceHelpers.swift b/Source/ImageSourceHelpers.swift index 1661245..bf7fb65 100755 --- a/Source/ImageSourceHelpers.swift +++ b/Source/ImageSourceHelpers.swift @@ -11,11 +11,12 @@ let defaultDuration: Double = 0 func CGImageSourceGIFFrameDuration(imageSource: CGImageSource, index: Int) -> NSTimeInterval { if !imageSource.isAnimatedGIF { return 0.0 } - let duration = imageSource.GIFPropertiesAtIndex(index) - >>- durationFromGIFProperties - >>- capDuration + guard let properties = imageSource.GIFPropertiesAtIndex(index), + let duration = durationFromGIFProperties(properties), + let cappedDuration = capDuration(duration) + else { return defaultDuration } - return duration ?? defaultDuration + return cappedDuration } /// Ensures that a duration is never smaller than a threshold value. diff --git a/Source/Info.plist b/Source/Info.plist index 05ccf4b..a4b68b8 100644 --- a/Source/Info.plist +++ b/Source/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 87 + 91 NSPrincipalClass