appjam 0.1.8.8 → 0.1.8.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +22 -62
- data/lib/appjam/generators/gist.yml +1 -1
- data/lib/appjam/generators/templates/blank/EiffelApplication.xcodeproj/project.pbxproj +1166 -482
- data/lib/appjam/generators/templates/blank/EiffelApplication.xcodeproj/project.xcworkspace/xcuserdata/eiffel.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/EiffelApplication-Prefix.pch.tt +26 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/AwesomeMenu.h +52 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/AwesomeMenu.m +412 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/AwesomeMenuItem.h +44 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/AwesomeMenuItem.m +97 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/bg-addbutton-highlighted.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/bg-addbutton-highlighted@2x.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/bg-addbutton.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/bg-addbutton@2x.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/bg-menuitem-highlighted.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/bg-menuitem-highlighted@2x.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/bg-menuitem.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/bg-menuitem@2x.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/icon-plus-highlighted.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/icon-plus-highlighted@2x.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/icon-plus.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/icon-plus@2x.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/icon-star.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/icon-star@2x.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/CMPopTipView/CMPopTipView.h +167 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/CMPopTipView/CMPopTipView.m +639 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/FXLabel/FXLabel.h +97 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/FXLabel/FXLabel.m +1080 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/MBProgressHUD/MBProgressHUD.h +451 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/MBProgressHUD/MBProgressHUD.m +865 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/FacingView.h +42 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/FacingView.m +56 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/FoldView.h +90 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/FoldView.m +316 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/MultiFoldView.h +104 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/MultiFoldView.m +516 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/PaperFoldConstants.h +49 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/PaperFoldNavigationController.h +18 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/PaperFoldNavigationController.m +88 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/PaperFoldResources.bundle/swipe_guide_left.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/PaperFoldResources.bundle/swipe_guide_left@2x.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/PaperFoldResources.bundle/swipe_guide_right.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/PaperFoldResources.bundle/swipe_guide_right@2x.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/PaperFoldSwipeHintView.h +25 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/PaperFoldSwipeHintView.m +76 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/PaperFoldView.h +131 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/PaperFoldView.m +941 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/Resources/swipe_guide.psd +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/Resources/swipe_guide2.psd +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/ShadowView.h +46 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/ShadowView.m +82 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/TouchThroughUIView.h +39 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/TouchThroughUIView.m +72 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/UIView+Screenshot.h +42 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/UIView+Screenshot.m +100 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/NSBubbleData.h +34 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/NSBubbleData.m +140 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/UIBubbleHeaderTableViewCell.h +17 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/UIBubbleHeaderTableViewCell.m +57 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/UIBubbleTableView.h +30 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/UIBubbleTableView.m +233 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/UIBubbleTableViewCell.h +19 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/UIBubbleTableViewCell.m +122 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/UIBubbleTableViewDataSource.h +24 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/UIBubbleTypingTableViewCell.h +20 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/UIBubbleTypingTableViewCell.m +56 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/images/bubbleMine.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/images/bubbleMine@2x.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/images/bubbleSomeone.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/images/bubbleSomeone@2x.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/images/missingAvatar.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/images/missingAvatar@2x.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/images/typingMine.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/images/typingMine@2x.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/images/typingSomeone.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/images/typingSomeone@2x.png +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIGlossyButton/UIGlossyButton.h +124 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIGlossyButton/UIGlossyButton.m +545 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIGlossyButton/UIView+LayerEffects.h +22 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIGlossyButton/UIView+LayerEffects.m +32 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFIncrementalStore/AFIncrementalStore.h +344 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFIncrementalStore/AFIncrementalStore.m +848 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFIncrementalStore/AFRESTClient.h +135 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFIncrementalStore/AFRESTClient.m +441 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/InflectorKit/NSString+InflectorKit.h +40 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/InflectorKit/NSString+InflectorKit.m +36 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/InflectorKit/TTTStringInflector.h +76 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/InflectorKit/TTTStringInflector.m +270 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/MKAnnotationView+WebCache.h +95 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/MKAnnotationView+WebCache.m +78 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDImageCache.h +144 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDImageCache.m +311 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImageCompat.h +40 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImageCompat.m +54 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImageDecoder.h +18 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImageDecoder.m +70 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImageDownloader.h +102 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImageDownloader.m +226 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImageDownloaderOperation.h +25 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImageDownloaderOperation.m +339 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImageManager.h +167 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImageManager.m +244 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImageOperation.h +15 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImagePrefetcher.h +58 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImagePrefetcher.m +127 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/UIButton+WebCache.h +173 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/UIButton+WebCache.m +129 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/UIImageView+WebCache.h +140 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/UIImageView+WebCache.m +84 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CPAnimationSequence/CPAnimationProgram.h +28 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CPAnimationSequence/CPAnimationSequence.h +28 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CPAnimationSequence/CPAnimationStep.h +49 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CPAnimationSequence/private/CPAnimationProgram.m +100 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CPAnimationSequence/private/CPAnimationSequence.m +85 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CPAnimationSequence/private/CPAnimationStep.m +122 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaAsyncSocket/GCDAsyncSocket.h +1074 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaAsyncSocket/GCDAsyncSocket.m +7430 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Categories/DDData.h +14 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Categories/DDData.m +158 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Categories/DDNumber.h +12 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Categories/DDNumber.m +88 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Categories/DDRange.h +56 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Categories/DDRange.m +104 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/HTTPAuthenticationRequest.h +45 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/HTTPAuthenticationRequest.m +195 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/HTTPConnection.h +119 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/HTTPConnection.m +2708 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/HTTPLogging.h +136 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/HTTPMessage.h +48 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/HTTPMessage.m +113 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/HTTPResponse.h +149 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/HTTPServer.h +205 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/HTTPServer.m +772 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Mime/MultipartFormDataParser.h +65 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Mime/MultipartFormDataParser.m +529 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Mime/MultipartMessageHeader.h +33 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Mime/MultipartMessageHeader.m +86 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Mime/MultipartMessageHeaderField.h +23 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Mime/MultipartMessageHeaderField.m +211 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Responses/HTTPAsyncFileResponse.h +75 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Responses/HTTPAsyncFileResponse.m +405 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Responses/HTTPDataResponse.h +13 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Responses/HTTPDataResponse.m +79 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Responses/HTTPDynamicFileResponse.h +52 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Responses/HTTPDynamicFileResponse.m +292 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Responses/HTTPErrorResponse.h +9 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Responses/HTTPErrorResponse.m +38 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Responses/HTTPFileResponse.h +25 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Responses/HTTPFileResponse.m +237 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Responses/HTTPRedirectResponse.h +12 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Responses/HTTPRedirectResponse.m +73 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/WebSocket.h +105 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/WebSocket.m +791 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Extensions/WebDAV/DAVConnection.h +7 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Extensions/WebDAV/DAVConnection.m +160 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Extensions/WebDAV/DAVResponse.h +11 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Extensions/WebDAV/DAVResponse.m +372 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Extensions/WebDAV/DELETEResponse.h +7 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Extensions/WebDAV/DELETEResponse.m +49 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Extensions/WebDAV/PUTResponse.h +8 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Extensions/WebDAV/PUTResponse.m +69 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/hpple/TFHpple.h +54 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/hpple/TFHpple.m +102 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/hpple/TFHppleElement.h +103 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/hpple/TFHppleElement.m +200 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/hpple/XPathQuery.h +10 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/hpple/XPathQuery.m +197 -0
- data/lib/appjam/version.rb +1 -1
- metadata +164 -3
@@ -0,0 +1,40 @@
|
|
1
|
+
/*
|
2
|
+
* This file is part of the SDWebImage package.
|
3
|
+
* (c) Olivier Poitrey <rs@dailymotion.com>
|
4
|
+
* (c) Jamie Pinkham
|
5
|
+
*
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
7
|
+
* file that was distributed with this source code.
|
8
|
+
*/
|
9
|
+
|
10
|
+
#import <TargetConditionals.h>
|
11
|
+
|
12
|
+
#ifdef __OBJC_GC__
|
13
|
+
#error SDWebImage does not support Objective-C Garbage Collection
|
14
|
+
#endif
|
15
|
+
|
16
|
+
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0
|
17
|
+
#error SDWebImage doesn't support Deployement Target version < 5.0
|
18
|
+
#endif
|
19
|
+
|
20
|
+
#if !TARGET_OS_IPHONE
|
21
|
+
#import <AppKit/AppKit.h>
|
22
|
+
#ifndef UIImage
|
23
|
+
#define UIImage NSImage
|
24
|
+
#endif
|
25
|
+
#ifndef UIImageView
|
26
|
+
#define UIImageView NSImageView
|
27
|
+
#endif
|
28
|
+
#else
|
29
|
+
#import <UIKit/UIKit.h>
|
30
|
+
#endif
|
31
|
+
|
32
|
+
#if OS_OBJECT_USE_OBJC
|
33
|
+
#define SDDispatchQueueRelease(q)
|
34
|
+
#define SDDispatchQueueSetterSementics strong
|
35
|
+
#else
|
36
|
+
#define SDDispatchQueueRelease(q) (dispatch_release(q))
|
37
|
+
#define SDDispatchQueueSetterSementics assign
|
38
|
+
#endif
|
39
|
+
|
40
|
+
extern inline UIImage *SDScaledImageForPath(NSString *path, NSObject *imageOrData);
|
@@ -0,0 +1,54 @@
|
|
1
|
+
//
|
2
|
+
// SDWebImageCompat.m
|
3
|
+
// SDWebImage
|
4
|
+
//
|
5
|
+
// Created by Olivier Poitrey on 11/12/12.
|
6
|
+
// Copyright (c) 2012 Dailymotion. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#import "SDWebImageCompat.h"
|
10
|
+
|
11
|
+
#if !__has_feature(objc_arc)
|
12
|
+
#error SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc flag
|
13
|
+
#endif
|
14
|
+
|
15
|
+
inline UIImage *SDScaledImageForPath(NSString *path, NSObject *imageOrData)
|
16
|
+
{
|
17
|
+
if (!imageOrData)
|
18
|
+
{
|
19
|
+
return nil;
|
20
|
+
}
|
21
|
+
|
22
|
+
UIImage *image = nil;
|
23
|
+
if ([imageOrData isKindOfClass:[NSData class]])
|
24
|
+
{
|
25
|
+
image = [[UIImage alloc] initWithData:(NSData *)imageOrData];
|
26
|
+
}
|
27
|
+
else if ([imageOrData isKindOfClass:[UIImage class]])
|
28
|
+
{
|
29
|
+
image = (UIImage *)imageOrData;
|
30
|
+
}
|
31
|
+
else
|
32
|
+
{
|
33
|
+
return nil;
|
34
|
+
}
|
35
|
+
|
36
|
+
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
|
37
|
+
{
|
38
|
+
CGFloat scale = 1.0;
|
39
|
+
if (path.length >= 8)
|
40
|
+
{
|
41
|
+
// Search @2x. at the end of the string, before a 3 to 4 extension length (only if key len is 8 or more @2x. + 4 len ext)
|
42
|
+
NSRange range = [path rangeOfString:@"@2x." options:0 range:NSMakeRange(path.length - 8, 5)];
|
43
|
+
if (range.location != NSNotFound)
|
44
|
+
{
|
45
|
+
scale = 2.0;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
UIImage *scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation];
|
50
|
+
image = scaledImage;
|
51
|
+
}
|
52
|
+
|
53
|
+
return image;
|
54
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
/*
|
2
|
+
* This file is part of the SDWebImage package.
|
3
|
+
* (c) Olivier Poitrey <rs@dailymotion.com>
|
4
|
+
*
|
5
|
+
* Created by james <https://github.com/mystcolor> on 9/28/11.
|
6
|
+
*
|
7
|
+
* For the full copyright and license information, please view the LICENSE
|
8
|
+
* file that was distributed with this source code.
|
9
|
+
*/
|
10
|
+
|
11
|
+
#import <Foundation/Foundation.h>
|
12
|
+
#import "SDWebImageCompat.h"
|
13
|
+
|
14
|
+
@interface UIImage (ForceDecode)
|
15
|
+
|
16
|
+
+ (UIImage *)decodedImageWithImage:(UIImage *)image;
|
17
|
+
|
18
|
+
@end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
/*
|
2
|
+
* This file is part of the SDWebImage package.
|
3
|
+
* (c) Olivier Poitrey <rs@dailymotion.com>
|
4
|
+
*
|
5
|
+
* Created by james <https://github.com/mystcolor> on 9/28/11.
|
6
|
+
*
|
7
|
+
* For the full copyright and license information, please view the LICENSE
|
8
|
+
* file that was distributed with this source code.
|
9
|
+
*/
|
10
|
+
|
11
|
+
#import "SDWebImageDecoder.h"
|
12
|
+
|
13
|
+
@implementation UIImage (ForceDecode)
|
14
|
+
|
15
|
+
+ (UIImage *)decodedImageWithImage:(UIImage *)image
|
16
|
+
{
|
17
|
+
CGImageRef imageRef = image.CGImage;
|
18
|
+
CGSize imageSize = CGSizeMake(CGImageGetWidth(imageRef), CGImageGetHeight(imageRef));
|
19
|
+
CGRect imageRect = (CGRect){.origin = CGPointZero, .size = imageSize};
|
20
|
+
|
21
|
+
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
|
22
|
+
CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef);
|
23
|
+
|
24
|
+
int infoMask = (bitmapInfo & kCGBitmapAlphaInfoMask);
|
25
|
+
BOOL anyNonAlpha = (infoMask == kCGImageAlphaNone ||
|
26
|
+
infoMask == kCGImageAlphaNoneSkipFirst ||
|
27
|
+
infoMask == kCGImageAlphaNoneSkipLast);
|
28
|
+
|
29
|
+
// CGBitmapContextCreate doesn't support kCGImageAlphaNone with RGB.
|
30
|
+
// https://developer.apple.com/library/mac/#qa/qa1037/_index.html
|
31
|
+
if (infoMask == kCGImageAlphaNone && CGColorSpaceGetNumberOfComponents(colorSpace) > 1)
|
32
|
+
{
|
33
|
+
// Unset the old alpha info.
|
34
|
+
bitmapInfo &= ~kCGBitmapAlphaInfoMask;
|
35
|
+
|
36
|
+
// Set noneSkipFirst.
|
37
|
+
bitmapInfo |= kCGImageAlphaNoneSkipFirst;
|
38
|
+
}
|
39
|
+
// Some PNGs tell us they have alpha but only 3 components. Odd.
|
40
|
+
else if (!anyNonAlpha && CGColorSpaceGetNumberOfComponents(colorSpace) == 3)
|
41
|
+
{
|
42
|
+
// Unset the old alpha info.
|
43
|
+
bitmapInfo &= ~kCGBitmapAlphaInfoMask;
|
44
|
+
bitmapInfo |= kCGImageAlphaPremultipliedFirst;
|
45
|
+
}
|
46
|
+
|
47
|
+
// It calculates the bytes-per-row based on the bitsPerComponent and width arguments.
|
48
|
+
CGContextRef context = CGBitmapContextCreate(NULL,
|
49
|
+
imageSize.width,
|
50
|
+
imageSize.height,
|
51
|
+
CGImageGetBitsPerComponent(imageRef),
|
52
|
+
0,
|
53
|
+
colorSpace,
|
54
|
+
bitmapInfo);
|
55
|
+
CGColorSpaceRelease(colorSpace);
|
56
|
+
|
57
|
+
// If failed, return undecompressed image
|
58
|
+
if (!context) return image;
|
59
|
+
|
60
|
+
CGContextDrawImage(context, imageRect, imageRef);
|
61
|
+
CGImageRef decompressedImageRef = CGBitmapContextCreateImage(context);
|
62
|
+
|
63
|
+
CGContextRelease(context);
|
64
|
+
|
65
|
+
UIImage *decompressedImage = [UIImage imageWithCGImage:decompressedImageRef scale:image.scale orientation:image.imageOrientation];
|
66
|
+
CGImageRelease(decompressedImageRef);
|
67
|
+
return decompressedImage;
|
68
|
+
}
|
69
|
+
|
70
|
+
@end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
/*
|
2
|
+
* This file is part of the SDWebImage package.
|
3
|
+
* (c) Olivier Poitrey <rs@dailymotion.com>
|
4
|
+
*
|
5
|
+
* For the full copyright and license information, please view the LICENSE
|
6
|
+
* file that was distributed with this source code.
|
7
|
+
*/
|
8
|
+
|
9
|
+
#import <Foundation/Foundation.h>
|
10
|
+
#import "SDWebImageCompat.h"
|
11
|
+
#import "SDWebImageOperation.h"
|
12
|
+
|
13
|
+
typedef enum
|
14
|
+
{
|
15
|
+
SDWebImageDownloaderLowPriority = 1 << 0,
|
16
|
+
SDWebImageDownloaderProgressiveDownload = 1 << 1,
|
17
|
+
/**
|
18
|
+
* By default, request prevent the of NSURLCache. With this flag, NSURLCache
|
19
|
+
* is used with default policies.
|
20
|
+
*/
|
21
|
+
SDWebImageDownloaderUseNSURLCache = 1 << 2,
|
22
|
+
/**
|
23
|
+
* Call completion block with nil image/imageData if the image was read from NSURLCache
|
24
|
+
* (to be combined with `SDWebImageDownloaderUseNSURLCache`).
|
25
|
+
*/
|
26
|
+
SDWebImageDownloaderIgnoreCachedResponse = 1 << 3
|
27
|
+
} SDWebImageDownloaderOptions;
|
28
|
+
|
29
|
+
typedef enum
|
30
|
+
{
|
31
|
+
SDWebImageDownloaderFIFOExecutionOrder,
|
32
|
+
/**
|
33
|
+
* Default value. All download operations will execute in queue style (first-in-first-out).
|
34
|
+
*/
|
35
|
+
SDWebImageDownloaderLIFOExecutionOrder
|
36
|
+
/**
|
37
|
+
* All download operations will execute in stack style (last-in-first-out).
|
38
|
+
*/
|
39
|
+
} SDWebImageDownloaderExecutionOrder;
|
40
|
+
|
41
|
+
extern NSString *const SDWebImageDownloadStartNotification;
|
42
|
+
extern NSString *const SDWebImageDownloadStopNotification;
|
43
|
+
|
44
|
+
typedef void(^SDWebImageDownloaderProgressBlock)(NSUInteger receivedSize, long long expectedSize);
|
45
|
+
typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage *image, NSData *data, NSError *error, BOOL finished);
|
46
|
+
|
47
|
+
/**
|
48
|
+
* Asynchronous downloader dedicated and optimized for image loading.
|
49
|
+
*/
|
50
|
+
@interface SDWebImageDownloader : NSObject
|
51
|
+
|
52
|
+
@property (assign, nonatomic) NSInteger maxConcurrentDownloads;
|
53
|
+
|
54
|
+
/**
|
55
|
+
* Changes download operations execution order. Default value is `SDWebImageDownloaderFIFOExecutionOrder`.
|
56
|
+
*/
|
57
|
+
@property (assign, nonatomic) SDWebImageDownloaderExecutionOrder executionOrder;
|
58
|
+
|
59
|
+
+ (SDWebImageDownloader *)sharedDownloader;
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Set a value for a HTTP header to be appended to each download HTTP request.
|
63
|
+
*
|
64
|
+
* @param value The value for the header field. Use `nil` value to remove the header.
|
65
|
+
* @param field The name of the header field to set.
|
66
|
+
*/
|
67
|
+
- (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field;
|
68
|
+
|
69
|
+
/**
|
70
|
+
* Returns the value of the specified HTTP header field.
|
71
|
+
*
|
72
|
+
* @return The value associated with the header field field, or `nil` if there is no corresponding header field.
|
73
|
+
*/
|
74
|
+
- (NSString *)valueForHTTPHeaderField:(NSString *)field;
|
75
|
+
|
76
|
+
/**
|
77
|
+
* Creates a SDWebImageDownloader async downloader instance with a given URL
|
78
|
+
*
|
79
|
+
* The delegate will be informed when the image is finish downloaded or an error has happen.
|
80
|
+
*
|
81
|
+
* @see SDWebImageDownloaderDelegate
|
82
|
+
*
|
83
|
+
* @param url The URL to the image to download
|
84
|
+
* @param options The options to be used for this download
|
85
|
+
* @param progress A block called repeatedly while the image is downloading
|
86
|
+
* @param completed A block called once the download is completed.
|
87
|
+
* If the download succeeded, the image parameter is set, in case of error,
|
88
|
+
* error parameter is set with the error. The last parameter is always YES
|
89
|
+
* if SDWebImageDownloaderProgressiveDownload isn't use. With the
|
90
|
+
* SDWebImageDownloaderProgressiveDownload option, this block is called
|
91
|
+
* repeatedly with the partial image object and the finished argument set to NO
|
92
|
+
* before to be called a last time with the full image and finished argument
|
93
|
+
* set to YES. In case of error, the finished argument is always YES.
|
94
|
+
*
|
95
|
+
* @return A cancellable SDWebImageOperation
|
96
|
+
*/
|
97
|
+
- (id<SDWebImageOperation>)downloadImageWithURL:(NSURL *)url
|
98
|
+
options:(SDWebImageDownloaderOptions)options
|
99
|
+
progress:(SDWebImageDownloaderProgressBlock)progressBlock
|
100
|
+
completed:(SDWebImageDownloaderCompletedBlock)completedBlock;
|
101
|
+
|
102
|
+
@end
|
@@ -0,0 +1,226 @@
|
|
1
|
+
/*
|
2
|
+
* This file is part of the SDWebImage package.
|
3
|
+
* (c) Olivier Poitrey <rs@dailymotion.com>
|
4
|
+
*
|
5
|
+
* For the full copyright and license information, please view the LICENSE
|
6
|
+
* file that was distributed with this source code.
|
7
|
+
*/
|
8
|
+
|
9
|
+
#import "SDWebImageDownloader.h"
|
10
|
+
#import "SDWebImageDownloaderOperation.h"
|
11
|
+
#import <ImageIO/ImageIO.h>
|
12
|
+
|
13
|
+
NSString *const SDWebImageDownloadStartNotification = @"SDWebImageDownloadStartNotification";
|
14
|
+
NSString *const SDWebImageDownloadStopNotification = @"SDWebImageDownloadStopNotification";
|
15
|
+
|
16
|
+
static NSString *const kProgressCallbackKey = @"progress";
|
17
|
+
static NSString *const kCompletedCallbackKey = @"completed";
|
18
|
+
|
19
|
+
@interface SDWebImageDownloader ()
|
20
|
+
|
21
|
+
@property (strong, nonatomic) NSOperationQueue *downloadQueue;
|
22
|
+
@property (weak, nonatomic) NSOperation *lastAddedOperation;
|
23
|
+
@property (strong, nonatomic) NSMutableDictionary *URLCallbacks;
|
24
|
+
@property (strong, nonatomic) NSMutableDictionary *HTTPHeaders;
|
25
|
+
// This queue is used to serialize the handling of the network responses of all the download operation in a single queue
|
26
|
+
@property (SDDispatchQueueSetterSementics, nonatomic) dispatch_queue_t workingQueue;
|
27
|
+
@property (SDDispatchQueueSetterSementics, nonatomic) dispatch_queue_t barrierQueue;
|
28
|
+
|
29
|
+
@end
|
30
|
+
|
31
|
+
@implementation SDWebImageDownloader
|
32
|
+
|
33
|
+
+ (void)initialize
|
34
|
+
{
|
35
|
+
// Bind SDNetworkActivityIndicator if available (download it here: http://github.com/rs/SDNetworkActivityIndicator )
|
36
|
+
// To use it, just add #import "SDNetworkActivityIndicator.h" in addition to the SDWebImage import
|
37
|
+
if (NSClassFromString(@"SDNetworkActivityIndicator"))
|
38
|
+
{
|
39
|
+
|
40
|
+
#pragma clang diagnostic push
|
41
|
+
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
|
42
|
+
id activityIndicator = [NSClassFromString(@"SDNetworkActivityIndicator") performSelector:NSSelectorFromString(@"sharedActivityIndicator")];
|
43
|
+
#pragma clang diagnostic pop
|
44
|
+
|
45
|
+
// Remove observer in case it was previously added.
|
46
|
+
[[NSNotificationCenter defaultCenter] removeObserver:activityIndicator name:SDWebImageDownloadStartNotification object:nil];
|
47
|
+
[[NSNotificationCenter defaultCenter] removeObserver:activityIndicator name:SDWebImageDownloadStopNotification object:nil];
|
48
|
+
|
49
|
+
[[NSNotificationCenter defaultCenter] addObserver:activityIndicator
|
50
|
+
selector:NSSelectorFromString(@"startActivity")
|
51
|
+
name:SDWebImageDownloadStartNotification object:nil];
|
52
|
+
[[NSNotificationCenter defaultCenter] addObserver:activityIndicator
|
53
|
+
selector:NSSelectorFromString(@"stopActivity")
|
54
|
+
name:SDWebImageDownloadStopNotification object:nil];
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
+ (SDWebImageDownloader *)sharedDownloader
|
59
|
+
{
|
60
|
+
static dispatch_once_t once;
|
61
|
+
static id instance;
|
62
|
+
dispatch_once(&once, ^{instance = self.new;});
|
63
|
+
return instance;
|
64
|
+
}
|
65
|
+
|
66
|
+
- (id)init
|
67
|
+
{
|
68
|
+
if ((self = [super init]))
|
69
|
+
{
|
70
|
+
_executionOrder = SDWebImageDownloaderFIFOExecutionOrder;
|
71
|
+
_downloadQueue = NSOperationQueue.new;
|
72
|
+
_downloadQueue.maxConcurrentOperationCount = 2;
|
73
|
+
_URLCallbacks = NSMutableDictionary.new;
|
74
|
+
_HTTPHeaders = [NSMutableDictionary dictionaryWithObject:@"image/*" forKey:@"Accept"];
|
75
|
+
_workingQueue = dispatch_queue_create("com.hackemist.SDWebImageDownloader", DISPATCH_QUEUE_SERIAL);
|
76
|
+
_barrierQueue = dispatch_queue_create("com.hackemist.SDWebImageDownloaderBarrierQueue", DISPATCH_QUEUE_CONCURRENT);
|
77
|
+
}
|
78
|
+
return self;
|
79
|
+
}
|
80
|
+
|
81
|
+
- (void)dealloc
|
82
|
+
{
|
83
|
+
[self.downloadQueue cancelAllOperations];
|
84
|
+
SDDispatchQueueRelease(_workingQueue);
|
85
|
+
SDDispatchQueueRelease(_barrierQueue);
|
86
|
+
}
|
87
|
+
|
88
|
+
- (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field
|
89
|
+
{
|
90
|
+
if (value)
|
91
|
+
{
|
92
|
+
self.HTTPHeaders[field] = value;
|
93
|
+
}
|
94
|
+
else
|
95
|
+
{
|
96
|
+
[self.HTTPHeaders removeObjectForKey:field];
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
- (NSString *)valueForHTTPHeaderField:(NSString *)field
|
101
|
+
{
|
102
|
+
return self.HTTPHeaders[field];
|
103
|
+
}
|
104
|
+
|
105
|
+
- (void)setMaxConcurrentDownloads:(NSInteger)maxConcurrentDownloads
|
106
|
+
{
|
107
|
+
_downloadQueue.maxConcurrentOperationCount = maxConcurrentDownloads;
|
108
|
+
}
|
109
|
+
|
110
|
+
- (NSInteger)maxConcurrentDownloads
|
111
|
+
{
|
112
|
+
return _downloadQueue.maxConcurrentOperationCount;
|
113
|
+
}
|
114
|
+
|
115
|
+
- (id<SDWebImageOperation>)downloadImageWithURL:(NSURL *)url options:(SDWebImageDownloaderOptions)options progress:(void (^)(NSUInteger, long long))progressBlock completed:(void (^)(UIImage *, NSData *, NSError *, BOOL))completedBlock
|
116
|
+
{
|
117
|
+
__block SDWebImageDownloaderOperation *operation;
|
118
|
+
__weak SDWebImageDownloader *wself = self;
|
119
|
+
|
120
|
+
[self addProgressCallback:progressBlock andCompletedBlock:completedBlock forURL:url createCallback:^
|
121
|
+
{
|
122
|
+
// In order to prevent from potential duplicate caching (NSURLCache + SDImageCache) we disable the cache for image requests if told otherwise
|
123
|
+
NSMutableURLRequest *request = [NSMutableURLRequest.alloc initWithURL:url cachePolicy:(options & SDWebImageDownloaderUseNSURLCache ? NSURLRequestUseProtocolCachePolicy : NSURLRequestReloadIgnoringLocalCacheData) timeoutInterval:15];
|
124
|
+
request.HTTPShouldHandleCookies = NO;
|
125
|
+
request.HTTPShouldUsePipelining = YES;
|
126
|
+
request.allHTTPHeaderFields = wself.HTTPHeaders;
|
127
|
+
operation = [SDWebImageDownloaderOperation.alloc initWithRequest:request queue:wself.workingQueue options:options progress:^(NSUInteger receivedSize, long long expectedSize)
|
128
|
+
{
|
129
|
+
if (!wself) return;
|
130
|
+
SDWebImageDownloader *sself = wself;
|
131
|
+
NSArray *callbacksForURL = [sself callbacksForURL:url];
|
132
|
+
for (NSDictionary *callbacks in callbacksForURL)
|
133
|
+
{
|
134
|
+
SDWebImageDownloaderProgressBlock callback = callbacks[kProgressCallbackKey];
|
135
|
+
if (callback) callback(receivedSize, expectedSize);
|
136
|
+
}
|
137
|
+
}
|
138
|
+
completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished)
|
139
|
+
{
|
140
|
+
if (!wself) return;
|
141
|
+
SDWebImageDownloader *sself = wself;
|
142
|
+
NSArray *callbacksForURL = [sself callbacksForURL:url];
|
143
|
+
if (finished)
|
144
|
+
{
|
145
|
+
[sself removeCallbacksForURL:url];
|
146
|
+
}
|
147
|
+
for (NSDictionary *callbacks in callbacksForURL)
|
148
|
+
{
|
149
|
+
SDWebImageDownloaderCompletedBlock callback = callbacks[kCompletedCallbackKey];
|
150
|
+
if (callback) callback(image, data, error, finished);
|
151
|
+
}
|
152
|
+
}
|
153
|
+
cancelled:^
|
154
|
+
{
|
155
|
+
if (!wself) return;
|
156
|
+
SDWebImageDownloader *sself = wself;
|
157
|
+
[sself callbacksForURL:url];
|
158
|
+
[sself removeCallbacksForURL:url];
|
159
|
+
}];
|
160
|
+
[wself.downloadQueue addOperation:operation];
|
161
|
+
if (wself.executionOrder == SDWebImageDownloaderLIFOExecutionOrder)
|
162
|
+
{
|
163
|
+
// Emulate LIFO execution order by systematically adding new operations as last operation's dependency
|
164
|
+
[wself.lastAddedOperation addDependency:operation];
|
165
|
+
wself.lastAddedOperation = operation;
|
166
|
+
}
|
167
|
+
}];
|
168
|
+
|
169
|
+
return operation;
|
170
|
+
}
|
171
|
+
|
172
|
+
- (void)addProgressCallback:(void (^)(NSUInteger, long long))progressBlock andCompletedBlock:(void (^)(UIImage *, NSData *data, NSError *, BOOL))completedBlock forURL:(NSURL *)url createCallback:(void (^)())createCallback
|
173
|
+
{
|
174
|
+
// The URL will be used as the key to the callbacks dictionary so it cannot be nil. If it is nil immediately call the completed block with no image or data.
|
175
|
+
if(url == nil)
|
176
|
+
{
|
177
|
+
if (completedBlock != nil)
|
178
|
+
{
|
179
|
+
completedBlock(nil, nil, nil, NO);
|
180
|
+
}
|
181
|
+
return;
|
182
|
+
}
|
183
|
+
|
184
|
+
dispatch_barrier_sync(self.barrierQueue, ^
|
185
|
+
{
|
186
|
+
BOOL first = NO;
|
187
|
+
if (!self.URLCallbacks[url])
|
188
|
+
{
|
189
|
+
self.URLCallbacks[url] = NSMutableArray.new;
|
190
|
+
first = YES;
|
191
|
+
}
|
192
|
+
|
193
|
+
// Handle single download of simultaneous download request for the same URL
|
194
|
+
NSMutableArray *callbacksForURL = self.URLCallbacks[url];
|
195
|
+
NSMutableDictionary *callbacks = NSMutableDictionary.new;
|
196
|
+
if (progressBlock) callbacks[kProgressCallbackKey] = [progressBlock copy];
|
197
|
+
if (completedBlock) callbacks[kCompletedCallbackKey] = [completedBlock copy];
|
198
|
+
[callbacksForURL addObject:callbacks];
|
199
|
+
self.URLCallbacks[url] = callbacksForURL;
|
200
|
+
|
201
|
+
if (first)
|
202
|
+
{
|
203
|
+
createCallback();
|
204
|
+
}
|
205
|
+
});
|
206
|
+
}
|
207
|
+
|
208
|
+
- (NSArray *)callbacksForURL:(NSURL *)url
|
209
|
+
{
|
210
|
+
__block NSArray *callbacksForURL;
|
211
|
+
dispatch_sync(self.barrierQueue, ^
|
212
|
+
{
|
213
|
+
callbacksForURL = self.URLCallbacks[url];
|
214
|
+
});
|
215
|
+
return callbacksForURL;
|
216
|
+
}
|
217
|
+
|
218
|
+
- (void)removeCallbacksForURL:(NSURL *)url
|
219
|
+
{
|
220
|
+
dispatch_barrier_async(self.barrierQueue, ^
|
221
|
+
{
|
222
|
+
[self.URLCallbacks removeObjectForKey:url];
|
223
|
+
});
|
224
|
+
}
|
225
|
+
|
226
|
+
@end
|