Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add an example for canceling an ongoing download.

  • Loading branch information...
commit 9107c2788a89e7b58ba116f1339a56c5f1bc432f 1 parent 1249a1b
@norsez authored
View
2  BDMultiDownloader/BDCacheDemoViewController.h
@@ -17,4 +17,6 @@
- (IBAction)didPressStart:(id)sender;
- (IBAction)didCancel:(id)sender;
+- (IBAction)didStop1:(id)sender;
+- (IBAction)didStop2:(id)sender;
@end
View
12 BDMultiDownloader/BDCacheDemoViewController.m
@@ -96,6 +96,18 @@ - (void)didCancel:(id)sender
self.startButton.enabled = YES;
}
+- (void)didStop1:(id)sender
+{
+ //This demonstates how to cancel an ongoing downloading.
+ //This only works while the download hasn't finished, apparently.
+ [[BDMultiDownloader shared] dequeueWithPath:kPathImage1];
+}
+
+- (void)didStop2:(id)sender
+{
+ [[BDMultiDownloader shared] dequeueWithPath:kPathImage2];
+}
+
@synthesize startButton;
@synthesize imageView2;
@synthesize progressBar;
View
151 BDMultiDownloader/BDCacheDemoViewController.xib
@@ -42,7 +42,6 @@
<int key="NSvFlags">274</int>
<string key="NSFrame">{{33, 27}, {255, 136}}</string>
<reference key="NSSuperview" ref="191373211"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="350273537"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIClipsSubviews">YES</bool>
@@ -55,7 +54,6 @@
<int key="NSvFlags">292</int>
<string key="NSFrame">{{33, 192}, {255, 130}}</string>
<reference key="NSSuperview" ref="191373211"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1056894797"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIClipsSubviews">YES</bool>
@@ -66,10 +64,9 @@
<object class="IBUIProgressView" id="350273537">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
- <string key="NSFrame">{{33, 171}, {255, 9}}</string>
+ <string key="NSFrame">{{33, 171}, {208, 9}}</string>
<reference key="NSSuperview" ref="191373211"/>
- <reference key="NSWindow"/>
- <reference key="NSNextKeyView" ref="510764588"/>
+ <reference key="NSNextKeyView" ref="1039505006"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
@@ -77,9 +74,8 @@
<object class="IBUIProgressView" id="1056894797">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
- <string key="NSFrame">{{33, 330}, {255, 9}}</string>
+ <string key="NSFrame">{{33, 330}, {208, 9}}</string>
<reference key="NSSuperview" ref="191373211"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="138696564"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
@@ -90,7 +86,6 @@
<int key="NSvFlags">292</int>
<string key="NSFrame">{{167, 356}, {121, 37}}</string>
<reference key="NSSuperview" ref="191373211"/>
- <reference key="NSWindow"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
@@ -125,7 +120,6 @@
<int key="NSvFlags">292</int>
<string key="NSFrame">{{44, 356}, {121, 37}}</string>
<reference key="NSSuperview" ref="191373211"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="33225230"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
@@ -143,10 +137,57 @@
<reference key="IBUIFontDescription" ref="448517276"/>
<reference key="IBUIFont" ref="775122982"/>
</object>
+ <object class="IBUIButton" id="1039505006">
+ <reference key="NSNextResponder" ref="191373211"/>
+ <int key="NSvFlags">292</int>
+ <string key="NSFrame">{{247, 164}, {38, 23}}</string>
+ <reference key="NSSuperview" ref="191373211"/>
+ <reference key="NSNextKeyView" ref="510764588"/>
+ <string key="NSReuseIdentifierKey">_NS:9</string>
+ <bool key="IBUIOpaque">NO</bool>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ <int key="IBUIContentHorizontalAlignment">0</int>
+ <int key="IBUIContentVerticalAlignment">0</int>
+ <string key="IBUINormalTitle">Stop</string>
+ <reference key="IBUIHighlightedTitleColor" ref="891710592"/>
+ <object class="NSColor" key="IBUINormalTitleColor">
+ <int key="NSColorSpace">1</int>
+ <bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
+ </object>
+ <reference key="IBUINormalTitleShadowColor" ref="820703812"/>
+ <object class="IBUIFontDescription" key="IBUIFontDescription" id="1052276234">
+ <int key="type">2</int>
+ <double key="pointSize">13</double>
+ </object>
+ <object class="NSFont" key="IBUIFont" id="176248088">
+ <string key="NSName">Helvetica-Bold</string>
+ <double key="NSSize">13</double>
+ <int key="NSfFlags">16</int>
+ </object>
+ </object>
+ <object class="IBUIButton" id="554789004">
+ <reference key="NSNextResponder" ref="191373211"/>
+ <int key="NSvFlags">292</int>
+ <string key="NSFrame">{{247, 323}, {38, 23}}</string>
+ <reference key="NSSuperview" ref="191373211"/>
+ <string key="NSReuseIdentifierKey">_NS:9</string>
+ <bool key="IBUIOpaque">NO</bool>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ <int key="IBUIContentHorizontalAlignment">0</int>
+ <int key="IBUIContentVerticalAlignment">0</int>
+ <string key="IBUINormalTitle">Stop</string>
+ <reference key="IBUIHighlightedTitleColor" ref="891710592"/>
+ <object class="NSColor" key="IBUINormalTitleColor">
+ <int key="NSColorSpace">1</int>
+ <bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
+ </object>
+ <reference key="IBUINormalTitleShadowColor" ref="820703812"/>
+ <reference key="IBUIFontDescription" ref="1052276234"/>
+ <reference key="IBUIFont" ref="176248088"/>
+ </object>
</array>
<string key="NSFrame">{{0, 20}, {320, 460}}</string>
<reference key="NSSuperview"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="684266310"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
@@ -227,6 +268,24 @@
</object>
<int key="connectionID">17</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchEventConnection" key="connection">
+ <string key="label">didStop1:</string>
+ <reference key="source" ref="1039505006"/>
+ <reference key="destination" ref="372490531"/>
+ <int key="IBEventType">7</int>
+ </object>
+ <int key="connectionID">20</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchEventConnection" key="connection">
+ <string key="label">didStop2:</string>
+ <reference key="source" ref="554789004"/>
+ <reference key="destination" ref="372490531"/>
+ <int key="IBEventType">7</int>
+ </object>
+ <int key="connectionID">21</int>
+ </object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
@@ -246,6 +305,8 @@
<reference ref="1056894797"/>
<reference ref="33225230"/>
<reference ref="138696564"/>
+ <reference ref="1039505006"/>
+ <reference ref="554789004"/>
</array>
<reference key="parent" ref="0"/>
</object>
@@ -290,6 +351,16 @@
<reference key="object" ref="138696564"/>
<reference key="parent" ref="191373211"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">18</int>
+ <reference key="object" ref="1039505006"/>
+ <reference key="parent" ref="191373211"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">19</int>
+ <reference key="object" ref="554789004"/>
+ <reference key="parent" ref="191373211"/>
+ </object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
@@ -299,6 +370,8 @@
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="15.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="18.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="19.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="4.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="5.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="6.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
@@ -309,63 +382,9 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
- <int key="maxID">17</int>
- </object>
- <object class="IBClassDescriber" key="IBDocument.Classes">
- <array class="NSMutableArray" key="referencedPartialClassDescriptions">
- <object class="IBPartialClassDescription">
- <string key="className">BDCacheDemoViewController</string>
- <string key="superclassName">UIViewController</string>
- <dictionary class="NSMutableDictionary" key="actions">
- <string key="didCancel:">id</string>
- <string key="didPressStart:">id</string>
- </dictionary>
- <dictionary class="NSMutableDictionary" key="actionInfosByName">
- <object class="IBActionInfo" key="didCancel:">
- <string key="name">didCancel:</string>
- <string key="candidateClassName">id</string>
- </object>
- <object class="IBActionInfo" key="didPressStart:">
- <string key="name">didPressStart:</string>
- <string key="candidateClassName">id</string>
- </object>
- </dictionary>
- <dictionary class="NSMutableDictionary" key="outlets">
- <string key="imageView">UIImageView</string>
- <string key="imageView2">UIImageView</string>
- <string key="progressBar">UIProgressView</string>
- <string key="progressBar2">UIProgressView</string>
- <string key="startButton">UIButton</string>
- </dictionary>
- <dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
- <object class="IBToOneOutletInfo" key="imageView">
- <string key="name">imageView</string>
- <string key="candidateClassName">UIImageView</string>
- </object>
- <object class="IBToOneOutletInfo" key="imageView2">
- <string key="name">imageView2</string>
- <string key="candidateClassName">UIImageView</string>
- </object>
- <object class="IBToOneOutletInfo" key="progressBar">
- <string key="name">progressBar</string>
- <string key="candidateClassName">UIProgressView</string>
- </object>
- <object class="IBToOneOutletInfo" key="progressBar2">
- <string key="name">progressBar2</string>
- <string key="candidateClassName">UIProgressView</string>
- </object>
- <object class="IBToOneOutletInfo" key="startButton">
- <string key="name">startButton</string>
- <string key="candidateClassName">UIButton</string>
- </object>
- </dictionary>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBProjectSource</string>
- <string key="minorKey">./Classes/BDCacheDemoViewController.h</string>
- </object>
- </object>
- </array>
+ <int key="maxID">21</int>
</object>
+ <object class="IBClassDescriber" key="IBDocument.Classes"/>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
View
1  Classes/BDMultiDownloader.h
@@ -59,6 +59,7 @@
- (void) clearQueue;
/**
* Cancel a download using download path.
+ * @path the download path to dequeue (to cancel.)
*/
- (void) dequeueWithPath:(NSString*)path;
Please sign in to comment.
Something went wrong with that request. Please try again.