14 | #endif
15 |
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Image.html:
--------------------------------------------------------------------------------
1 | Offline Images
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "scale" : "1x",
6 | "size" : "57x57"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "scale" : "2x",
11 | "size" : "57x57"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "scale" : "2x",
16 | "size" : "60x60"
17 | },
18 | {
19 | "idiom" : "ipad",
20 | "scale" : "1x",
21 | "size" : "72x72"
22 | },
23 | {
24 | "idiom" : "ipad",
25 | "scale" : "2x",
26 | "size" : "72x72"
27 | },
28 | {
29 | "idiom" : "ipad",
30 | "scale" : "1x",
31 | "size" : "76x76"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "scale" : "2x",
36 | "size" : "76x76"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "scale" : "1x",
41 | "size" : "29x29"
42 | },
43 | {
44 | "idiom" : "iphone",
45 | "scale" : "2x",
46 | "size" : "29x29"
47 | },
48 | {
49 | "idiom" : "iphone",
50 | "scale" : "2x",
51 | "size" : "40x40"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "scale" : "1x",
56 | "size" : "50x50"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "scale" : "2x",
61 | "size" : "50x50"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "scale" : "1x",
66 | "size" : "40x40"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "scale" : "2x",
71 | "size" : "40x40"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "scale" : "1x",
76 | "size" : "29x29"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "scale" : "2x",
81 | "size" : "29x29"
82 | }
83 | ],
84 | "info" : {
85 | "version" : 1,
86 | "author" : "xcode"
87 | }
88 | }
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Images.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "scale" : "1x",
6 | "orientation" : "portrait"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "scale" : "2x",
11 | "orientation" : "portrait"
12 | },
13 | {
14 | "orientation" : "portrait",
15 | "idiom" : "iphone",
16 | "subtype" : "retina4",
17 | "scale" : "2x"
18 | },
19 | {
20 | "orientation" : "portrait",
21 | "idiom" : "iphone",
22 | "minimum-system-version" : "7.0",
23 | "scale" : "2x"
24 | },
25 | {
26 | "orientation" : "portrait",
27 | "idiom" : "iphone",
28 | "minimum-system-version" : "7.0",
29 | "subtype" : "retina4",
30 | "scale" : "2x"
31 | },
32 | {
33 | "orientation" : "portrait",
34 | "idiom" : "ipad",
35 | "extent" : "to-status-bar",
36 | "scale" : "1x"
37 | },
38 | {
39 | "orientation" : "portrait",
40 | "idiom" : "ipad",
41 | "extent" : "to-status-bar",
42 | "scale" : "2x"
43 | },
44 | {
45 | "orientation" : "landscape",
46 | "idiom" : "ipad",
47 | "extent" : "to-status-bar",
48 | "scale" : "1x"
49 | },
50 | {
51 | "orientation" : "landscape",
52 | "idiom" : "ipad",
53 | "extent" : "to-status-bar",
54 | "scale" : "2x"
55 | },
56 | {
57 | "orientation" : "portrait",
58 | "idiom" : "ipad",
59 | "minimum-system-version" : "7.0",
60 | "extent" : "full-screen",
61 | "scale" : "1x"
62 | },
63 | {
64 | "orientation" : "portrait",
65 | "idiom" : "ipad",
66 | "minimum-system-version" : "7.0",
67 | "extent" : "full-screen",
68 | "scale" : "2x"
69 | },
70 | {
71 | "orientation" : "landscape",
72 | "idiom" : "ipad",
73 | "minimum-system-version" : "7.0",
74 | "extent" : "full-screen",
75 | "scale" : "1x"
76 | },
77 | {
78 | "orientation" : "landscape",
79 | "idiom" : "ipad",
80 | "minimum-system-version" : "7.0",
81 | "extent" : "full-screen",
82 | "scale" : "2x"
83 | }
84 | ],
85 | "info" : {
86 | "version" : 1,
87 | "author" : "xcode"
88 | }
89 | }
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Images.xcassets/book.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x",
6 | "filename" : "book.png"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x",
11 | "filename" : "book@2x.png"
12 | }
13 | ],
14 | "info" : {
15 | "version" : 1,
16 | "author" : "xcode"
17 | }
18 | }
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Images.xcassets/book.imageset/book.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mureev/CMHTMLView/15e8a0be3c6dea45a2560c7000aafad6345caba4/Demo/Demo/Resources/Images.xcassets/book.imageset/book.png
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Images.xcassets/book.imageset/book@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mureev/CMHTMLView/15e8a0be3c6dea45a2560c7000aafad6345caba4/Demo/Demo/Resources/Images.xcassets/book.imageset/book@2x.png
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Images.xcassets/icon-ipad.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x",
6 | "filename" : "icon-ipad.png"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | }
12 | ],
13 | "info" : {
14 | "version" : 1,
15 | "author" : "xcode"
16 | }
17 | }
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Images.xcassets/icon-ipad.imageset/icon-ipad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mureev/CMHTMLView/15e8a0be3c6dea45a2560c7000aafad6345caba4/Demo/Demo/Resources/Images.xcassets/icon-ipad.imageset/icon-ipad.png
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Images.xcassets/icon-iphone.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x",
6 | "filename" : "icon-iphone.png"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x",
11 | "filename" : "icon-iphone@2x.png"
12 | }
13 | ],
14 | "info" : {
15 | "version" : 1,
16 | "author" : "xcode"
17 | }
18 | }
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Images.xcassets/icon-iphone.imageset/icon-iphone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mureev/CMHTMLView/15e8a0be3c6dea45a2560c7000aafad6345caba4/Demo/Demo/Resources/Images.xcassets/icon-iphone.imageset/icon-iphone.png
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Images.xcassets/icon-iphone.imageset/icon-iphone@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mureev/CMHTMLView/15e8a0be3c6dea45a2560c7000aafad6345caba4/Demo/Demo/Resources/Images.xcassets/icon-iphone.imageset/icon-iphone@2x.png
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Images.xcassets/image.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x",
6 | "filename" : "image.png"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x",
11 | "filename" : "image@2x.png"
12 | }
13 | ],
14 | "info" : {
15 | "version" : 1,
16 | "author" : "xcode"
17 | }
18 | }
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Images.xcassets/image.imageset/image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mureev/CMHTMLView/15e8a0be3c6dea45a2560c7000aafad6345caba4/Demo/Demo/Resources/Images.xcassets/image.imageset/image.png
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Images.xcassets/image.imageset/image@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mureev/CMHTMLView/15e8a0be3c6dea45a2560c7000aafad6345caba4/Demo/Demo/Resources/Images.xcassets/image.imageset/image@2x.png
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Images.xcassets/pixel.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x",
6 | "filename" : "pixel.png"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | }
12 | ],
13 | "info" : {
14 | "version" : 1,
15 | "author" : "xcode"
16 | }
17 | }
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Images.xcassets/pixel.imageset/pixel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mureev/CMHTMLView/15e8a0be3c6dea45a2560c7000aafad6345caba4/Demo/Demo/Resources/Images.xcassets/pixel.imageset/pixel.png
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Images.xcassets/text.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x",
6 | "filename" : "text.png"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x",
11 | "filename" : "text@2x.png"
12 | }
13 | ],
14 | "info" : {
15 | "version" : 1,
16 | "author" : "xcode"
17 | }
18 | }
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Images.xcassets/text.imageset/text.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mureev/CMHTMLView/15e8a0be3c6dea45a2560c7000aafad6345caba4/Demo/Demo/Resources/Images.xcassets/text.imageset/text.png
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Images.xcassets/text.imageset/text@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mureev/CMHTMLView/15e8a0be3c6dea45a2560c7000aafad6345caba4/Demo/Demo/Resources/Images.xcassets/text.imageset/text@2x.png
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Images.xcassets/translucent.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x",
6 | "filename" : "translucent.png"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x",
11 | "filename" : "translucent@2x.png"
12 | }
13 | ],
14 | "info" : {
15 | "version" : 1,
16 | "author" : "xcode"
17 | }
18 | }
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Images.xcassets/translucent.imageset/translucent.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mureev/CMHTMLView/15e8a0be3c6dea45a2560c7000aafad6345caba4/Demo/Demo/Resources/Images.xcassets/translucent.imageset/translucent.png
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Images.xcassets/translucent.imageset/translucent@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mureev/CMHTMLView/15e8a0be3c6dea45a2560c7000aafad6345caba4/Demo/Demo/Resources/Images.xcassets/translucent.imageset/translucent@2x.png
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Images.xcassets/video.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x",
6 | "filename" : "video.png"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x",
11 | "filename" : "video@2x.png"
12 | }
13 | ],
14 | "info" : {
15 | "version" : 1,
16 | "author" : "xcode"
17 | }
18 | }
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Images.xcassets/video.imageset/video.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mureev/CMHTMLView/15e8a0be3c6dea45a2560c7000aafad6345caba4/Demo/Demo/Resources/Images.xcassets/video.imageset/video.png
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Images.xcassets/video.imageset/video@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mureev/CMHTMLView/15e8a0be3c6dea45a2560c7000aafad6345caba4/Demo/Demo/Resources/Images.xcassets/video.imageset/video@2x.png
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Simple.html:
--------------------------------------------------------------------------------
1 | List Styles
2 | A variety of list styles are supported.
3 |
4 | - First
5 | - Second
6 | - Third
7 |
8 |
9 | Nesting
10 | Nesting is supported.
11 |
12 | Unordered Lists
13 |
14 | - First item
15 | - Second item
16 |
17 | - Nested unordered lists
18 | - Nested line 2
19 | -
20 |
21 | - Nested list the third.
22 | - Nested list the third.
23 |
24 |
25 |
26 |
27 | - Last item
28 |
29 |
30 |
31 | Ordered Lists
32 |
33 | - First item
34 | - Second item
35 |
36 | - Nested unordered lists
37 | - Nested line 2
38 | -
39 |
40 | - Nested list the third.
41 | - Nested list the third.
42 |
43 |
44 |
45 |
46 | - Last item
47 |
48 |
49 | Mixed Lists
50 |
51 | - First item
52 | - Second item
53 |
54 | - Nested unordered lists
55 | - Nested line 2
56 | -
57 |
58 | - Nested list the third.
59 | - Nested list the third.
60 |
61 |
62 |
63 |
64 | - Last item
65 |
66 |
67 |
68 | - First item
69 | - Second item
70 |
71 | - Nested unordered lists
72 | - Nested line 2
73 | -
74 |
75 | - Nested list the third.
76 | - Nested list the third.
77 |
78 |
79 |
80 |
81 | - Last item
82 |
83 |
84 | Images
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 | Text Alignment
93 | Supported are all text alignment options via CSS text-align or the center tag.
94 | text-align: left, right, center, justify, inherit
95 |
96 | Examples
97 |
98 | Right
Center Left
99 |
100 | Right to Left
101 |
102 | بِسۡمِ ٱللَّهِ ٱلرَّحۡمَٰنِ ٱلرَّحِيمِ
103 | بسم الله الرحمن الرحيم
--------------------------------------------------------------------------------
/Demo/Demo/Resources/Video.html:
--------------------------------------------------------------------------------
1 | Video
2 | HTML5 Video
3 |
6 |
9 |
10 | YouTube in IFRAME
11 |
12 |
13 | YouTube in object embed
14 |
15 |
16 | Vimeo in IFRAME
17 | The Mountain from TSO Photography on Vimeo.
--------------------------------------------------------------------------------
/Demo/Demo/ViewControllers/HugeTextViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // HugeTextViewController.h
3 | //
4 | // Created by Constantine Mureev on 16.02.12.
5 | // Copyright (c) 2012 Team Force LLC. All rights reserved.
6 | //
7 |
8 | #import
9 |
10 | @interface HugeTextViewController : UIViewController
11 |
12 | @end
13 |
--------------------------------------------------------------------------------
/Demo/Demo/ViewControllers/HugeTextViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // HugeTextViewController.m
3 | //
4 | // Created by Constantine Mureev on 16.02.12.
5 | // Copyright (c) 2012 Team Force LLC. All rights reserved.
6 | //
7 |
8 | #import "HugeTextViewController.h"
9 | #import "CMHTMLView.h"
10 |
11 |
12 | @interface HugeTextViewController ()
13 |
14 | @end
15 |
16 | @implementation HugeTextViewController
17 |
18 |
19 | - (void)viewDidLoad {
20 | [super viewDidLoad];
21 |
22 | CMHTMLView* htmlView = [[CMHTMLView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
23 | htmlView.delegate = self;
24 | htmlView.alpha = 0;
25 | htmlView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
26 | [self.view addSubview:htmlView];
27 |
28 | [htmlView loadHtmlBody:[self readHTMLContentFromFile:@"WarAndPeace"]];
29 | }
30 |
31 | - (NSString *)readHTMLContentFromFile:(NSString *)fileName {
32 | NSString* filePath = [[NSBundle mainBundle] pathForResource:fileName ofType:@"html"];
33 | NSData* htmlData = [NSData dataWithContentsOfFile:filePath];
34 | NSString* htmlString = [[NSString alloc] initWithData:htmlData encoding:NSUTF8StringEncoding];
35 | return htmlString;
36 | }
37 |
38 |
39 | #pragma mark - CMHTMLViewDelegate
40 |
41 |
42 | - (void)htmlViewDidFinishLoad:(CMHTMLView *)htmlView withError:(NSError *)error {
43 | if (!error) {
44 | [UIView animateWithDuration:0.2 animations:^{
45 | htmlView.alpha = 1;
46 | }];
47 | } else {
48 | htmlView.alpha = 0;
49 | }
50 | }
51 |
52 | - (void)htmlViewDidTapImage:(CMHTMLView *)htmlView imageUrl:(NSString *)imageUrl {
53 | UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Image!" message:imageUrl delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil];
54 | [alert show];
55 | }
56 |
57 | - (void)htmlViewDidTapLink:(CMHTMLView *)htmlView linkUrl:(NSString *)linkUrl {
58 | UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"URL!" message:linkUrl delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil];
59 | [alert show];
60 | }
61 |
62 | @end
--------------------------------------------------------------------------------
/Demo/Demo/ViewControllers/OfflineImagesViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // OfflineImagesViewController.h
3 | //
4 | // Created by Constantine Mureev on 16.02.12.
5 | // Copyright (c) 2012 Team Force LLC. All rights reserved.
6 | //
7 |
8 | #import
9 |
10 | @interface OfflineImagesViewController : UIViewController
11 |
12 | @end
13 |
--------------------------------------------------------------------------------
/Demo/Demo/ViewControllers/OfflineImagesViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // OfflineImagesViewController.m
3 | //
4 | // Created by Constantine Mureev on 16.02.12.
5 | // Copyright (c) 2012 Team Force LLC. All rights reserved.
6 | //
7 |
8 | #import "OfflineImagesViewController.h"
9 |
10 | #import
11 | #import
12 |
13 | #import "CMHTMLView.h"
14 |
15 | @interface OfflineImagesViewController ()
16 |
17 | @end
18 |
19 | @implementation OfflineImagesViewController
20 |
21 |
22 | - (void)viewDidLoad {
23 | [super viewDidLoad];
24 |
25 | CMHTMLView* htmlView = [[CMHTMLView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
26 | htmlView.delegate = self;
27 | htmlView.alpha = 0;
28 | htmlView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
29 | [self.view addSubview:htmlView];
30 |
31 | htmlView.blockTags = [NSArray arrayWithObjects:@"iframe", nil];
32 | htmlView.defaultImagePath = [[[NSBundle mainBundle] URLForResource:@"pixel" withExtension:@"png"] absoluteString];
33 |
34 |
35 | NSString *html = [self readHTMLContentFromFile:@"Image"];
36 | html = [html prepareHTMLAndRemoveTags:@[@"div"]];
37 | [htmlView loadHtmlBody:html];
38 | }
39 |
40 | - (NSString *)readHTMLContentFromFile:(NSString *)fileName {
41 | NSString* filePath = [[NSBundle mainBundle] pathForResource:fileName ofType:@"html"];
42 | NSData* htmlData = [NSData dataWithContentsOfFile:filePath];
43 | NSString* htmlString = [[NSString alloc] initWithData:htmlData encoding:NSUTF8StringEncoding];
44 | return htmlString;
45 | }
46 |
47 |
48 | #pragma mark - CMHTMLViewDelegate
49 |
50 |
51 | - (void)htmlViewDidFinishLoad:(CMHTMLView *)htmlView withError:(NSError *)error {
52 | if (!error) {
53 | [UIView animateWithDuration:0.2 animations:^{
54 | htmlView.alpha = 1;
55 | }];
56 | } else {
57 | htmlView.alpha = 0;
58 | }
59 | }
60 |
61 | - (void)htmlViewWillWaitForImage:(CMHTMLView *)htmlView imageUrl:(NSString *)url imagePath:(SetImagePathBlock)path {
62 | if ([[CMDataStorage sharedCacheStorage] isStored:url]) {
63 | path([[[CMDataStorage sharedCacheStorage] fileURLWithKey:url] absoluteString]);
64 | } else {
65 | AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
66 | manager.responseSerializer = [AFHTTPResponseSerializer serializer];
67 |
68 | [manager GET:url parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
69 | NSData *data = responseObject;
70 |
71 | [[CMDataStorage sharedCacheStorage] writeData:data key:url block:^(BOOL succeeds) {
72 | path([[[CMDataStorage sharedCacheStorage] fileURLWithKey:url] absoluteString]);
73 | }];
74 | } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
75 | NSLog(@"Error: %@", error);
76 | }];
77 | }
78 | }
79 |
80 | - (void)htmlViewDidTapImage:(CMHTMLView *)htmlView imageUrl:(NSString *)imageUrl {
81 | UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Image!" message:imageUrl delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil];
82 | [alert show];
83 | }
84 |
85 | - (void)htmlViewDidTapLink:(CMHTMLView *)htmlView linkUrl:(NSString *)linkUrl {
86 | UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"URL!" message:linkUrl delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil];
87 | [alert show];
88 | }
89 |
90 | @end
--------------------------------------------------------------------------------
/Demo/Demo/ViewControllers/SimpleTextViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // SimpleTextViewController.h
3 | //
4 | // Created by Constantine Mureev on 16.02.12.
5 | // Copyright (c) 2012 Team Force LLC. All rights reserved.
6 | //
7 |
8 | #import
9 |
10 | @interface SimpleTextViewController : UIViewController
11 |
12 | @end
13 |
--------------------------------------------------------------------------------
/Demo/Demo/ViewControllers/SimpleTextViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // SimpleTextViewController.m
3 | //
4 | // Created by Constantine Mureev on 16.02.12.
5 | // Copyright (c) 2012 Team Force LLC. All rights reserved.
6 | //
7 |
8 | #import "SimpleTextViewController.h"
9 | #import "CMHTMLView.h"
10 |
11 |
12 | @interface SimpleTextViewController ()
13 |
14 | @end
15 |
16 | @implementation SimpleTextViewController
17 |
18 |
19 | - (void)viewDidLoad {
20 | [super viewDidLoad];
21 |
22 | CMHTMLView* htmlView = [[CMHTMLView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
23 | htmlView.delegate = self;
24 | htmlView.alpha = 0;
25 | htmlView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
26 | [self.view addSubview:htmlView];
27 |
28 | [htmlView loadHtmlBody:[self readHTMLContentFromFile:@"Simple"]];
29 | }
30 |
31 | - (NSString *)readHTMLContentFromFile:(NSString *)fileName {
32 | NSString* filePath = [[NSBundle mainBundle] pathForResource:fileName ofType:@"html"];
33 | NSData* htmlData = [NSData dataWithContentsOfFile:filePath];
34 | NSString* htmlString = [[NSString alloc] initWithData:htmlData encoding:NSUTF8StringEncoding];
35 | return htmlString;
36 | }
37 |
38 |
39 | #pragma mark - CMHTMLViewDelegate
40 |
41 |
42 | - (void)htmlViewDidFinishLoad:(CMHTMLView *)htmlView withError:(NSError *)error {
43 | if (!error) {
44 | [UIView animateWithDuration:0.2 animations:^{
45 | htmlView.alpha = 1;
46 | }];
47 | } else {
48 | htmlView.alpha = 0;
49 | }
50 | }
51 |
52 | - (void)htmlViewDidTapImage:(CMHTMLView *)htmlView imageUrl:(NSString *)imageUrl {
53 | UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Image!" message:imageUrl delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil];
54 | [alert show];
55 | }
56 |
57 | - (void)htmlViewDidTapLink:(CMHTMLView *)htmlView linkUrl:(NSString *)linkUrl {
58 | UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"URL!" message:linkUrl delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil];
59 | [alert show];
60 | }
61 |
62 | @end
--------------------------------------------------------------------------------
/Demo/Demo/ViewControllers/TranslucentViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // TranslucentViewController.h
3 | //
4 | // Created by Constantine Mureev on 16.02.12.
5 | // Copyright (c) 2012 Team Force LLC. All rights reserved.
6 | //
7 |
8 | #import
9 |
10 | @interface TranslucentViewController : UIViewController
11 |
12 | @end
13 |
--------------------------------------------------------------------------------
/Demo/Demo/ViewControllers/TranslucentViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // TranslucentViewController.m
3 | //
4 | // Created by Constantine Mureev on 16.02.12.
5 | // Copyright (c) 2012 Team Force LLC. All rights reserved.
6 | //
7 |
8 | #import "TranslucentViewController.h"
9 |
10 | #import
11 | #import
12 |
13 | #import "CMHTMLView.h"
14 |
15 |
16 | @interface TranslucentViewController ()
17 |
18 | @end
19 |
20 | @implementation TranslucentViewController
21 |
22 |
23 | - (void)viewDidLoad {
24 | [super viewDidLoad];
25 |
26 | self.view.backgroundColor = [UIColor scrollViewTexturedBackgroundColor];
27 |
28 | CMHTMLView* htmlView = [[CMHTMLView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
29 | htmlView.backgroundColor = [UIColor clearColor];
30 | htmlView.delegate = self;
31 | htmlView.alpha = 0;
32 | htmlView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
33 | [self.view addSubview:htmlView];
34 |
35 | htmlView.blockTags = [NSArray arrayWithObjects:@"iframe", nil];
36 |
37 | htmlView.defaultImagePath = [[[NSBundle mainBundle] URLForResource:@"pixel" withExtension:@"png"] absoluteString];
38 | htmlView.webView.scrollView.contentInset = UIEdgeInsetsMake(44, 0, 0, 0);
39 | htmlView.webView.scrollView.scrollIndicatorInsets = UIEdgeInsetsMake(44, 0, 0, 0);
40 |
41 | [htmlView loadHtmlBody:[self readHTMLContentFromFile:@"Image"]];
42 | }
43 |
44 | - (NSString *)readHTMLContentFromFile:(NSString *)fileName {
45 | NSString* filePath = [[NSBundle mainBundle] pathForResource:fileName ofType:@"html"];
46 | NSData* htmlData = [NSData dataWithContentsOfFile:filePath];
47 | NSString* htmlString = [[NSString alloc] initWithData:htmlData encoding:NSUTF8StringEncoding];
48 | return htmlString;
49 | }
50 |
51 |
52 | #pragma mark - CMHTMLViewDelegate
53 |
54 |
55 | - (void)htmlViewDidFinishLoad:(CMHTMLView *)htmlView withError:(NSError *)error {
56 | if (!error) {
57 | [UIView animateWithDuration:0.2 animations:^{
58 | htmlView.alpha = 1;
59 | }];
60 | } else {
61 | htmlView.alpha = 0;
62 | }
63 | }
64 |
65 | - (void)htmlViewWillWaitForImage:(CMHTMLView *)htmlView imageUrl:(NSString *)url imagePath:(SetImagePathBlock)path {
66 | if ([[CMDataStorage sharedCacheStorage] isStored:url]) {
67 | path([[[CMDataStorage sharedCacheStorage] fileURLWithKey:url] absoluteString]);
68 | } else {
69 | AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
70 | manager.responseSerializer = [AFHTTPResponseSerializer serializer];
71 |
72 | [manager GET:url parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
73 | NSData *data = responseObject;
74 |
75 | [[CMDataStorage sharedCacheStorage] writeData:data key:url block:^(BOOL succeeds) {
76 | path([[[CMDataStorage sharedCacheStorage] fileURLWithKey:url] absoluteString]);
77 | }];
78 | } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
79 | NSLog(@"Error: %@", error);
80 | }];
81 | }
82 | }
83 |
84 | - (void)htmlViewDidTapImage:(CMHTMLView *)htmlView imageUrl:(NSString *)imageUrl {
85 | UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Image!" message:imageUrl delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil];
86 | [alert show];
87 | }
88 |
89 | - (void)htmlViewDidTapLink:(CMHTMLView *)htmlView linkUrl:(NSString *)linkUrl {
90 | UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"URL!" message:linkUrl delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil];
91 | [alert show];
92 | }
93 |
94 | @end
--------------------------------------------------------------------------------
/Demo/Demo/ViewControllers/VideoViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // VideoViewController.h
3 | //
4 | // Created by Constantine Mureev on 16.02.12.
5 | // Copyright (c) 2012 Team Force LLC. All rights reserved.
6 | //
7 |
8 | #import
9 |
10 | @interface VideoViewController : UIViewController
11 |
12 | @end
13 |
--------------------------------------------------------------------------------
/Demo/Demo/ViewControllers/VideoViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // VideoViewController.m
3 | //
4 | // Created by Constantine Mureev on 16.02.12.
5 | // Copyright (c) 2012 Team Force LLC. All rights reserved.
6 | //
7 |
8 | #import "VideoViewController.h"
9 | #import "CMHTMLView.h"
10 |
11 |
12 | @implementation VideoViewController
13 |
14 |
15 | - (void)viewDidLoad {
16 | [super viewDidLoad];
17 |
18 | CMHTMLView* htmlView = [[CMHTMLView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
19 | htmlView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
20 | [self.view addSubview:htmlView];
21 |
22 | [htmlView loadHtmlBody:[self readHTMLContentFromFile:@"Video"]];
23 | }
24 |
25 | - (NSString *)readHTMLContentFromFile:(NSString *)fileName {
26 | NSString* filePath = [[NSBundle mainBundle] pathForResource:fileName ofType:@"html"];
27 | NSData* htmlData = [NSData dataWithContentsOfFile:filePath];
28 | NSString* htmlString = [[NSString alloc] initWithData:htmlData encoding:NSUTF8StringEncoding];
29 | return htmlString;
30 | }
31 |
32 | @end
--------------------------------------------------------------------------------
/Demo/Demo/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | //
4 | // Created by Constantine Mureev on 16.02.12.
5 | // Copyright (c) 2012 Team Force LLC. All rights reserved.
6 | //
7 |
8 | #import
9 |
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char *argv[])
13 | {
14 | @autoreleasepool {
15 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Demo/Podfile:
--------------------------------------------------------------------------------
1 | platform :ios, '6.0'
2 | pod 'AFNetworking'
3 | pod 'CMDataStorage'
--------------------------------------------------------------------------------
/Demo/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - AFNetworking (2.0.3):
3 | - AFNetworking/NSURLConnection
4 | - AFNetworking/NSURLSession
5 | - AFNetworking/Reachability
6 | - AFNetworking/Security
7 | - AFNetworking/Serialization
8 | - AFNetworking/UIKit
9 | - AFNetworking/NSURLConnection (2.0.3):
10 | - AFNetworking/Reachability
11 | - AFNetworking/Security
12 | - AFNetworking/Serialization
13 | - AFNetworking/NSURLSession (2.0.3):
14 | - AFNetworking/NSURLConnection
15 | - AFNetworking/Reachability (2.0.3)
16 | - AFNetworking/Security (2.0.3)
17 | - AFNetworking/Serialization (2.0.3)
18 | - AFNetworking/UIKit (2.0.3):
19 | - AFNetworking/NSURLConnection
20 | - CMDataStorage (1.1.0)
21 |
22 | DEPENDENCIES:
23 | - AFNetworking
24 | - CMDataStorage
25 |
26 | SPEC CHECKSUMS:
27 | AFNetworking: e499052cbf3d743e9bb727bb37adb9dc2547ba15
28 | CMDataStorage: 1d1f325b29e6b10bd2bc1858bdf838017be5219b
29 |
30 | COCOAPODS: 0.29.0
31 |
--------------------------------------------------------------------------------
/Demo/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h:
--------------------------------------------------------------------------------
1 | // AFHTTPRequestOperation.h
2 | //
3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 | #import "AFURLConnectionOperation.h"
25 | #import "AFURLResponseSerialization.h"
26 |
27 | /**
28 | `AFHTTPRequestOperation` is a subclass of `AFURLConnectionOperation` for requests using the HTTP or HTTPS protocols. It encapsulates the concept of acceptable status codes and content types, which determine the success or failure of a request.
29 | */
30 | @interface AFHTTPRequestOperation : AFURLConnectionOperation
31 |
32 | ///------------------------------------------------
33 | /// @name Getting HTTP URL Connection Information
34 | ///------------------------------------------------
35 |
36 | /**
37 | The last HTTP response received by the operation's connection.
38 | */
39 | @property (readonly, nonatomic, strong) NSHTTPURLResponse *response;
40 |
41 | /**
42 | Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an AFHTTPResoinse serializer, which uses the raw data as its response object. The serializer validates the status code to be in the `2XX` range, denoting success. If the response serializer generates an error in `-responseObjectForResponse:data:error:`, the `failure` callback of the session task or request operation will be executed; otherwise, the `success` callback will be executed.
43 |
44 | @warning `responseSerializer` must not be `nil`. Setting a response serializer will clear out any cached value
45 | */
46 | @property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer;
47 |
48 | /**
49 | An object constructed by the `responseSerializer` from the response and response data. Returns `nil` unless the operation `isFinished`, has a `response`, and has `responseData` with non-zero content length. If an error occurs during serialization, `nil` will be returned, and the `error` property will be populated with the serialization error.
50 | */
51 | @property (readonly, nonatomic, strong) id responseObject;
52 |
53 | ///-----------------------------------------------------------
54 | /// @name Setting Completion Block Success / Failure Callbacks
55 | ///-----------------------------------------------------------
56 |
57 | /**
58 | Sets the `completionBlock` property with a block that executes either the specified success or failure block, depending on the state of the request on completion. If `error` returns a value, which can be caused by an unacceptable status code or content type, then `failure` is executed. Otherwise, `success` is executed.
59 |
60 | This method should be overridden in subclasses in order to specify the response object passed into the success block.
61 |
62 | @param success The block to be executed on the completion of a successful request. This block has no return value and takes two arguments: the receiver operation and the object constructed from the response data of the request.
63 | @param failure The block to be executed on the completion of an unsuccessful request. This block has no return value and takes two arguments: the receiver operation and the error that occurred during the request.
64 | */
65 | - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
66 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
67 |
68 | @end
69 |
--------------------------------------------------------------------------------
/Demo/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m:
--------------------------------------------------------------------------------
1 | // AFHTTPRequestOperation.m
2 | //
3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "AFHTTPRequestOperation.h"
24 |
25 | static dispatch_queue_t http_request_operation_processing_queue() {
26 | static dispatch_queue_t af_http_request_operation_processing_queue;
27 | static dispatch_once_t onceToken;
28 | dispatch_once(&onceToken, ^{
29 | af_http_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.http-request.processing", DISPATCH_QUEUE_CONCURRENT);
30 | });
31 |
32 | return af_http_request_operation_processing_queue;
33 | }
34 |
35 | static dispatch_group_t http_request_operation_completion_group() {
36 | static dispatch_group_t af_http_request_operation_completion_group;
37 | static dispatch_once_t onceToken;
38 | dispatch_once(&onceToken, ^{
39 | af_http_request_operation_completion_group = dispatch_group_create();
40 | });
41 |
42 | return af_http_request_operation_completion_group;
43 | }
44 |
45 | #pragma mark -
46 |
47 | @interface AFHTTPRequestOperation ()
48 | @property (readwrite, nonatomic, strong) NSURLRequest *request;
49 | @property (readwrite, nonatomic, strong) NSHTTPURLResponse *response;
50 | @property (readwrite, nonatomic, strong) id responseObject;
51 | @property (readwrite, nonatomic, strong) NSError *responseSerializationError;
52 | @property (readwrite, nonatomic, strong) NSRecursiveLock *lock;
53 | @end
54 |
55 | @implementation AFHTTPRequestOperation
56 | @dynamic lock;
57 |
58 | - (instancetype)initWithRequest:(NSURLRequest *)urlRequest {
59 | self = [super initWithRequest:urlRequest];
60 | if (!self) {
61 | return nil;
62 | }
63 |
64 | self.responseSerializer = [AFHTTPResponseSerializer serializer];
65 |
66 | return self;
67 | }
68 |
69 | - (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer {
70 | NSParameterAssert(responseSerializer);
71 |
72 | [self.lock lock];
73 | _responseSerializer = responseSerializer;
74 | self.responseObject = nil;
75 | self.responseSerializationError = nil;
76 | [self.lock unlock];
77 | }
78 |
79 | - (id)responseObject {
80 | [self.lock lock];
81 | if (!_responseObject && [self isFinished] && !self.error) {
82 | NSError *error = nil;
83 | self.responseObject = [self.responseSerializer responseObjectForResponse:self.response data:self.responseData error:&error];
84 | if (error) {
85 | self.responseSerializationError = error;
86 | }
87 | }
88 | [self.lock unlock];
89 |
90 | return _responseObject;
91 | }
92 |
93 | - (NSError *)error {
94 | if (_responseSerializationError) {
95 | return _responseSerializationError;
96 | } else {
97 | return [super error];
98 | }
99 | }
100 |
101 | #pragma mark - AFHTTPRequestOperation
102 |
103 | - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
104 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
105 | {
106 | // completionBlock is manually nilled out in AFURLConnectionOperation to break the retain cycle.
107 | #pragma clang diagnostic push
108 | #pragma clang diagnostic ignored "-Warc-retain-cycles"
109 | #pragma clang diagnostic ignored "-Wgnu"
110 | self.completionBlock = ^{
111 | if (self.completionGroup) {
112 | dispatch_group_enter(self.completionGroup);
113 | }
114 |
115 | dispatch_async(http_request_operation_processing_queue(), ^{
116 | if (self.error) {
117 | if (failure) {
118 | dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{
119 | failure(self, self.error);
120 | });
121 | }
122 | } else {
123 | id responseObject = self.responseObject;
124 | if (self.error) {
125 | if (failure) {
126 | dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{
127 | failure(self, self.error);
128 | });
129 | }
130 | } else {
131 | if (success) {
132 | dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{
133 | success(self, responseObject);
134 | });
135 | }
136 | }
137 | }
138 |
139 | if (self.completionGroup) {
140 | dispatch_group_leave(self.completionGroup);
141 | }
142 | });
143 | };
144 | #pragma clang diagnostic pop
145 | }
146 |
147 | #pragma mark - AFURLRequestOperation
148 |
149 | - (void)pause {
150 | int64_t offset = 0;
151 | if ([self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey]) {
152 | offset = [(NSNumber *)[self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey] longLongValue];
153 | } else {
154 | offset = [(NSData *)[self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey] length];
155 | }
156 |
157 | NSMutableURLRequest *mutableURLRequest = [self.request mutableCopy];
158 | if ([self.response respondsToSelector:@selector(allHeaderFields)] && [[self.response allHeaderFields] valueForKey:@"ETag"]) {
159 | [mutableURLRequest setValue:[[self.response allHeaderFields] valueForKey:@"ETag"] forHTTPHeaderField:@"If-Range"];
160 | }
161 | [mutableURLRequest setValue:[NSString stringWithFormat:@"bytes=%llu-", offset] forHTTPHeaderField:@"Range"];
162 | self.request = mutableURLRequest;
163 |
164 | [super pause];
165 | }
166 |
167 | #pragma mark - NSCoding
168 |
169 | - (id)initWithCoder:(NSCoder *)decoder {
170 | self = [super initWithCoder:decoder];
171 | if (!self) {
172 | return nil;
173 | }
174 |
175 | self.responseSerializer = [decoder decodeObjectForKey:NSStringFromSelector(@selector(responseSerializer))];
176 |
177 | return self;
178 | }
179 |
180 | - (void)encodeWithCoder:(NSCoder *)coder {
181 | [super encodeWithCoder:coder];
182 |
183 | [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))];
184 | }
185 |
186 | #pragma mark - NSCopying
187 |
188 | - (id)copyWithZone:(NSZone *)zone {
189 | AFHTTPRequestOperation *operation = [[[self class] allocWithZone:zone] initWithRequest:self.request];
190 |
191 | operation.responseSerializer = [self.responseSerializer copyWithZone:zone];
192 | operation.completionQueue = self.completionQueue;
193 | operation.completionGroup = self.completionGroup;
194 |
195 | return operation;
196 | }
197 |
198 | @end
199 |
--------------------------------------------------------------------------------
/Demo/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h:
--------------------------------------------------------------------------------
1 | // AFNetworkReachabilityManager.h
2 | //
3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 | #import
25 |
26 | #import
27 | #import
28 | #import
29 | #import
30 | #import
31 |
32 | typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) {
33 | AFNetworkReachabilityStatusUnknown = -1,
34 | AFNetworkReachabilityStatusNotReachable = 0,
35 | AFNetworkReachabilityStatusReachableViaWWAN = 1,
36 | AFNetworkReachabilityStatusReachableViaWiFi = 2,
37 | };
38 |
39 | /**
40 | `AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces.
41 |
42 | See Apple's Reachability Sample Code (https://developer.apple.com/library/ios/samplecode/reachability/)
43 | */
44 | @interface AFNetworkReachabilityManager : NSObject
45 |
46 | /**
47 | The current network reachability status.
48 | */
49 | @property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
50 |
51 | /**
52 | Whether or not the network is currently reachable.
53 | */
54 | @property (readonly, nonatomic, assign, getter = isReachable) BOOL reachable;
55 |
56 | /**
57 | Whether or not the network is currently reachable via WWAN.
58 | */
59 | @property (readonly, nonatomic, assign, getter = isReachableViaWWAN) BOOL reachableViaWWAN;
60 |
61 | /**
62 | Whether or not the network is currently reachable via WiFi.
63 | */
64 | @property (readonly, nonatomic, assign, getter = isReachableViaWiFi) BOOL reachableViaWiFi;
65 |
66 | ///---------------------
67 | /// @name Initialization
68 | ///---------------------
69 |
70 | /**
71 | Returns the shared network reachability manager.
72 | */
73 | + (instancetype)sharedManager;
74 |
75 | /**
76 | Creates and returns a network reachability manager for the specified domain.
77 |
78 | @param domain The domain used to evaluate network reachability.
79 |
80 | @return An initialized network reachability manager, actively monitoring the specified domain.
81 | */
82 | + (instancetype)managerForDomain:(NSString *)domain;
83 |
84 | /**
85 | Creates and returns a network reachability manager for the socket address.
86 |
87 | @param address The socket address used to evaluate network reachability.
88 |
89 | @return An initialized network reachability manager, actively monitoring the specified socket address.
90 | */
91 | + (instancetype)managerForAddress:(const struct sockaddr_in *)address;
92 |
93 | /**
94 | Initializes an instance of a network reachability manager from the specified reachability object.
95 |
96 | @param reachability The reachability object to monitor.
97 |
98 | @return An initialized network reachability manager, actively monitoring the specified reachability.
99 | */
100 | - (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability;
101 |
102 | ///--------------------------------------------------
103 | /// @name Starting & Stopping Reachability Monitoring
104 | ///--------------------------------------------------
105 |
106 | /**
107 | Starts monitoring for changes in network reachability status.
108 | */
109 | - (void)startMonitoring;
110 |
111 | /**
112 | Stops monitoring for changes in network reachability status.
113 | */
114 | - (void)stopMonitoring;
115 |
116 | ///-------------------------------------------------
117 | /// @name Getting Localized Reachability Description
118 | ///-------------------------------------------------
119 |
120 | /**
121 | Returns a localized string representation of the current network reachability status.
122 | */
123 | - (NSString *)localizedNetworkReachabilityStatusString;
124 |
125 | ///---------------------------------------------------
126 | /// @name Setting Network Reachability Change Callback
127 | ///---------------------------------------------------
128 |
129 | /**
130 | Sets a callback to be executed when the network availability of the `baseURL` host changes.
131 |
132 | @param block A block object to be executed when the network availability of the `baseURL` host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the `baseURL`.
133 | */
134 | - (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block;
135 |
136 | @end
137 |
138 | ///----------------
139 | /// @name Constants
140 | ///----------------
141 |
142 | /**
143 | ## Network Reachability
144 |
145 | The following constants are provided by `AFNetworkReachabilityManager` as possible network reachability statuses.
146 |
147 | enum {
148 | AFNetworkReachabilityStatusUnknown,
149 | AFNetworkReachabilityStatusNotReachable,
150 | AFNetworkReachabilityStatusReachableViaWWAN,
151 | AFNetworkReachabilityStatusReachableViaWiFi,
152 | }
153 |
154 | `AFNetworkReachabilityStatusUnknown`
155 | The `baseURL` host reachability is not known.
156 |
157 | `AFNetworkReachabilityStatusNotReachable`
158 | The `baseURL` host cannot be reached.
159 |
160 | `AFNetworkReachabilityStatusReachableViaWWAN`
161 | The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS.
162 |
163 | `AFNetworkReachabilityStatusReachableViaWiFi`
164 | The `baseURL` host can be reached via a Wi-Fi connection.
165 |
166 | ### Keys for Notification UserInfo Dictionary
167 |
168 | Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification.
169 |
170 | `AFNetworkingReachabilityNotificationStatusItem`
171 | A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification.
172 | The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status.
173 | */
174 |
175 | ///--------------------
176 | /// @name Notifications
177 | ///--------------------
178 |
179 | /**
180 | Posted when network reachability changes.
181 | This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability.
182 |
183 | @warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import ` to the header prefix of the project (`Prefix.pch`).
184 | */
185 | extern NSString * const AFNetworkingReachabilityDidChangeNotification;
186 | extern NSString * const AFNetworkingReachabilityNotificationStatusItem;
187 |
188 | ///--------------------
189 | /// @name Functions
190 | ///--------------------
191 |
192 | /**
193 | Returns a localized string representation of an `AFNetworkReachabilityStatus` value.
194 | */
195 | extern NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status);
196 |
--------------------------------------------------------------------------------
/Demo/Pods/AFNetworking/AFNetworking/AFNetworking.h:
--------------------------------------------------------------------------------
1 | // AFNetworking.h
2 | //
3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com/)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 | #import
25 |
26 | #ifndef _AFNETWORKING_
27 | #define _AFNETWORKING_
28 |
29 | #import "AFURLRequestSerialization.h"
30 | #import "AFURLResponseSerialization.h"
31 | #import "AFSecurityPolicy.h"
32 | #import "AFNetworkReachabilityManager.h"
33 |
34 | #import "AFURLConnectionOperation.h"
35 | #import "AFHTTPRequestOperation.h"
36 | #import "AFHTTPRequestOperationManager.h"
37 |
38 | #if ( ( defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) || \
39 | ( defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 ) )
40 | #import "AFURLSessionManager.h"
41 | #import "AFHTTPSessionManager.h"
42 | #endif
43 |
44 | #endif /* _AFNETWORKING_ */
45 |
--------------------------------------------------------------------------------
/Demo/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h:
--------------------------------------------------------------------------------
1 | // AFSecurity.h
2 | //
3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 | #import
25 |
26 | typedef NS_ENUM(NSUInteger, AFSSLPinningMode) {
27 | AFSSLPinningModeNone,
28 | AFSSLPinningModePublicKey,
29 | AFSSLPinningModeCertificate,
30 | };
31 |
32 | /**
33 | `AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections.
34 |
35 | Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled.
36 | */
37 | @interface AFSecurityPolicy : NSObject
38 |
39 | /**
40 | The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`.
41 | */
42 | @property (nonatomic, assign) AFSSLPinningMode SSLPinningMode;
43 |
44 | /**
45 | The certificates used to evaluate server trust according to the SSL pinning mode. By default, this property is set to any (`.cer`) certificates included in the app bundle.
46 | */
47 | @property (nonatomic, strong) NSArray *pinnedCertificates;
48 |
49 | /**
50 | Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`.
51 | */
52 | @property (nonatomic, assign) BOOL allowInvalidCertificates;
53 |
54 | ///-----------------------------------------
55 | /// @name Getting Specific Security Policies
56 | ///-----------------------------------------
57 |
58 | /**
59 | Returns the shared default security policy, which does not accept invalid certificates, and does not validate against pinned certificates or public keys.
60 |
61 | @return The default security policy.
62 | */
63 | + (instancetype)defaultPolicy;
64 |
65 | ///---------------------
66 | /// @name Initialization
67 | ///---------------------
68 |
69 | /**
70 | Creates and returns a security policy with the specified pinning mode.
71 |
72 | @param pinningMode The SSL pinning mode.
73 |
74 | @return A new security policy.
75 | */
76 | + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode;
77 |
78 | ///------------------------------
79 | /// @name Evaluating Server Trust
80 | ///------------------------------
81 |
82 | /**
83 | Whether or not the specified server trust should be accepted, based on the security policy.
84 |
85 | This method should be used when responding to an authentication challenge from a server.
86 |
87 | @param serverTrust The X.509 certificate trust of the server.
88 |
89 | @return Whether or not to trust the server.
90 | */
91 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust;
92 |
93 | @end
94 |
95 | ///----------------
96 | /// @name Constants
97 | ///----------------
98 |
99 | /**
100 | ## SSL Pinning Modes
101 |
102 | The following constants are provided by `AFSSLPinningMode` as possible SSL pinning modes.
103 |
104 | enum {
105 | AFSSLPinningModeNone,
106 | AFSSLPinningModePublicKey,
107 | AFSSLPinningModeCertificate,
108 | }
109 |
110 | `AFSSLPinningModeNone`
111 | Do not validate servers against pinned certificates.
112 |
113 | `AFSSLPinningModePublicKey`
114 | Validate host certificates against public keys of pinned certificates.
115 |
116 | `AFSSLPinningModeCertificate`
117 | Validate host certificates against pinned certificates.
118 | */
119 |
--------------------------------------------------------------------------------
/Demo/Pods/AFNetworking/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013 AFNetworking (http://afnetworking.com/)
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/Demo/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h:
--------------------------------------------------------------------------------
1 | // AFNetworkActivityIndicatorManager.h
2 | //
3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 |
25 | #import
26 |
27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
28 |
29 | #import
30 |
31 | /**
32 | `AFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. When enabled, it will listen for notifications indicating that a network request operation has started or finished, and start or stop animating the indicator accordingly. The number of active requests is incremented and decremented much like a stack or a semaphore, and the activity indicator will animate so long as that number is greater than zero.
33 |
34 | You should enable the shared instance of `AFNetworkActivityIndicatorManager` when your application finishes launching. In `AppDelegate application:didFinishLaunchingWithOptions:` you can do so with the following code:
35 |
36 | [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES];
37 |
38 | By setting `isNetworkActivityIndicatorVisible` to `YES` for `sharedManager`, the network activity indicator will show and hide automatically as requests start and finish. You should not ever need to call `incrementActivityCount` or `decrementActivityCount` yourself.
39 |
40 | See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information:
41 | http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44
42 | */
43 | @interface AFNetworkActivityIndicatorManager : NSObject
44 |
45 | /**
46 | A Boolean value indicating whether the manager is enabled.
47 |
48 | If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO.
49 | */
50 | @property (nonatomic, assign, getter = isEnabled) BOOL enabled;
51 |
52 | /**
53 | A Boolean value indicating whether the network activity indicator is currently displayed in the status bar.
54 | */
55 | @property (readonly, nonatomic, assign) BOOL isNetworkActivityIndicatorVisible;
56 |
57 | /**
58 | Returns the shared network activity indicator manager object for the system.
59 |
60 | @return The systemwide network activity indicator manager.
61 | */
62 | + (instancetype)sharedManager;
63 |
64 | /**
65 | Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator.
66 | */
67 | - (void)incrementActivityCount;
68 |
69 | /**
70 | Decrements the number of active network requests. If this number becomes zero before decrementing, this will stop animating the status bar network activity indicator.
71 | */
72 | - (void)decrementActivityCount;
73 |
74 | @end
75 |
76 | #endif
77 |
--------------------------------------------------------------------------------
/Demo/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m:
--------------------------------------------------------------------------------
1 | // AFNetworkActivityIndicatorManager.m
2 | //
3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "AFNetworkActivityIndicatorManager.h"
24 |
25 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
26 |
27 | #import "AFHTTPRequestOperation.h"
28 |
29 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
30 | #import "AFURLSessionManager.h"
31 | #endif
32 |
33 | static NSTimeInterval const kAFNetworkActivityIndicatorInvisibilityDelay = 0.17;
34 |
35 | static NSURLRequest * AFNetworkRequestFromNotification(NSNotification *notification) {
36 | if ([[notification object] isKindOfClass:[AFURLConnectionOperation class]]) {
37 | return [(AFURLConnectionOperation *)[notification object] request];
38 | }
39 |
40 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
41 | if ([[notification object] respondsToSelector:@selector(originalRequest)]) {
42 | return [(NSURLSessionTask *)[notification object] originalRequest];
43 | }
44 | #endif
45 |
46 | return nil;
47 | }
48 |
49 | @interface AFNetworkActivityIndicatorManager ()
50 | @property (readwrite, nonatomic, assign) NSInteger activityCount;
51 | @property (readwrite, nonatomic, strong) NSTimer *activityIndicatorVisibilityTimer;
52 | @property (readonly, nonatomic, getter = isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible;
53 |
54 | - (void)updateNetworkActivityIndicatorVisibility;
55 | - (void)updateNetworkActivityIndicatorVisibilityDelayed;
56 | @end
57 |
58 | @implementation AFNetworkActivityIndicatorManager
59 | @dynamic networkActivityIndicatorVisible;
60 |
61 | + (instancetype)sharedManager {
62 | static AFNetworkActivityIndicatorManager *_sharedManager = nil;
63 | static dispatch_once_t oncePredicate;
64 | dispatch_once(&oncePredicate, ^{
65 | _sharedManager = [[self alloc] init];
66 | });
67 |
68 | return _sharedManager;
69 | }
70 |
71 | + (NSSet *)keyPathsForValuesAffectingIsNetworkActivityIndicatorVisible {
72 | return [NSSet setWithObject:@"activityCount"];
73 | }
74 |
75 | - (id)init {
76 | self = [super init];
77 | if (!self) {
78 | return nil;
79 | }
80 |
81 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingOperationDidStartNotification object:nil];
82 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingOperationDidFinishNotification object:nil];
83 |
84 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
85 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingTaskDidStartNotification object:nil];
86 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidSuspendNotification object:nil];
87 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidFinishNotification object:nil];
88 | #endif
89 |
90 | return self;
91 | }
92 |
93 | - (void)dealloc {
94 | [[NSNotificationCenter defaultCenter] removeObserver:self];
95 |
96 | [_activityIndicatorVisibilityTimer invalidate];
97 | }
98 |
99 | - (void)updateNetworkActivityIndicatorVisibilityDelayed {
100 | if (self.enabled) {
101 | // Delay hiding of activity indicator for a short interval, to avoid flickering
102 | if (![self isNetworkActivityIndicatorVisible]) {
103 | [self.activityIndicatorVisibilityTimer invalidate];
104 | self.activityIndicatorVisibilityTimer = [NSTimer timerWithTimeInterval:kAFNetworkActivityIndicatorInvisibilityDelay target:self selector:@selector(updateNetworkActivityIndicatorVisibility) userInfo:nil repeats:NO];
105 | [[NSRunLoop mainRunLoop] addTimer:self.activityIndicatorVisibilityTimer forMode:NSRunLoopCommonModes];
106 | } else {
107 | [self performSelectorOnMainThread:@selector(updateNetworkActivityIndicatorVisibility) withObject:nil waitUntilDone:NO modes:@[NSRunLoopCommonModes]];
108 | }
109 | }
110 | }
111 |
112 | - (BOOL)isNetworkActivityIndicatorVisible {
113 | return self.activityCount > 0;
114 | }
115 |
116 | - (void)updateNetworkActivityIndicatorVisibility {
117 | [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:[self isNetworkActivityIndicatorVisible]];
118 | }
119 |
120 | - (void)setActivityCount:(NSInteger)activityCount {
121 | @synchronized(self) {
122 | _activityCount = activityCount;
123 | }
124 |
125 | dispatch_async(dispatch_get_main_queue(), ^{
126 | [self updateNetworkActivityIndicatorVisibilityDelayed];
127 | });
128 | }
129 |
130 | - (void)incrementActivityCount {
131 | [self willChangeValueForKey:@"activityCount"];
132 | @synchronized(self) {
133 | _activityCount++;
134 | }
135 | [self didChangeValueForKey:@"activityCount"];
136 |
137 | dispatch_async(dispatch_get_main_queue(), ^{
138 | [self updateNetworkActivityIndicatorVisibilityDelayed];
139 | });
140 | }
141 |
142 | - (void)decrementActivityCount {
143 | [self willChangeValueForKey:@"activityCount"];
144 | @synchronized(self) {
145 | #pragma clang diagnostic push
146 | #pragma clang diagnostic ignored "-Wgnu"
147 | _activityCount = MAX(_activityCount - 1, 0);
148 | #pragma clang diagnostic pop
149 | }
150 | [self didChangeValueForKey:@"activityCount"];
151 |
152 | dispatch_async(dispatch_get_main_queue(), ^{
153 | [self updateNetworkActivityIndicatorVisibilityDelayed];
154 | });
155 | }
156 |
157 | - (void)networkRequestDidStart:(NSNotification *)notification {
158 | if ([AFNetworkRequestFromNotification(notification) URL]) {
159 | [self incrementActivityCount];
160 | }
161 | }
162 |
163 | - (void)networkRequestDidFinish:(NSNotification *)notification {
164 | if ([AFNetworkRequestFromNotification(notification) URL]) {
165 | [self decrementActivityCount];
166 | }
167 | }
168 |
169 | @end
170 |
171 | #endif
172 |
--------------------------------------------------------------------------------
/Demo/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIActivityIndicatorView+AFNetworking.h
2 | //
3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 |
25 | #import
26 |
27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
28 |
29 | #import
30 |
31 |
32 | @class AFURLConnectionOperation;
33 |
34 | /**
35 | This category adds methods to the UIKit framework's `UIActivityIndicatorView` class. The methods in this category provide support for automatically starting and stopping animation depending on the loading state of a request operation or session task.
36 | */
37 | @interface UIActivityIndicatorView (AFNetworking)
38 |
39 | ///----------------------------------
40 | /// @name Animating for Session Tasks
41 | ///----------------------------------
42 |
43 | /**
44 | Binds the animating state to the state of the specified task.
45 |
46 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled.
47 | */
48 | #if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090)
49 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task;
50 | #endif
51 |
52 | ///---------------------------------------
53 | /// @name Animating for Request Operations
54 | ///---------------------------------------
55 |
56 | /**
57 | Binds the animating state to the execution state of the specified operation.
58 |
59 | @param operation The operation. If `nil`, automatic updating from any previously specified operation will be disabled.
60 | */
61 | - (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation;
62 |
63 | @end
64 |
65 | #endif
66 |
--------------------------------------------------------------------------------
/Demo/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m:
--------------------------------------------------------------------------------
1 | // UIActivityIndicatorView+AFNetworking.m
2 | //
3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "UIActivityIndicatorView+AFNetworking.h"
24 |
25 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
26 |
27 | #import "AFHTTPRequestOperation.h"
28 |
29 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
30 | #import "AFURLSessionManager.h"
31 | #endif
32 |
33 | @implementation UIActivityIndicatorView (AFNetworking)
34 |
35 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
36 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task {
37 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
38 |
39 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidStartNotification object:nil];
40 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil];
41 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidFinishNotification object:nil];
42 |
43 | if (task) {
44 | if (task.state != NSURLSessionTaskStateCompleted) {
45 | if (task.state == NSURLSessionTaskStateRunning) {
46 | [self startAnimating];
47 | } else {
48 | [self stopAnimating];
49 | }
50 |
51 | [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingTaskDidStartNotification object:task];
52 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidFinishNotification object:task];
53 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidSuspendNotification object:task];
54 | }
55 | }
56 | }
57 | #endif
58 |
59 | #pragma mark -
60 |
61 | - (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation {
62 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
63 |
64 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil];
65 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil];
66 |
67 | if (operation) {
68 | if (![operation isFinished]) {
69 | if ([operation isExecuting]) {
70 | [self startAnimating];
71 | } else {
72 | [self stopAnimating];
73 | }
74 |
75 | [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingOperationDidStartNotification object:operation];
76 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingOperationDidFinishNotification object:operation];
77 | }
78 | }
79 | }
80 |
81 | #pragma mark -
82 |
83 | - (void)af_startAnimating {
84 | dispatch_async(dispatch_get_main_queue(), ^{
85 | [self startAnimating];
86 | });
87 | }
88 |
89 | - (void)af_stopAnimating {
90 | dispatch_async(dispatch_get_main_queue(), ^{
91 | [self stopAnimating];
92 | });
93 | }
94 |
95 | @end
96 |
97 | #endif
98 |
--------------------------------------------------------------------------------
/Demo/Pods/AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIAlertView+AFNetworking.h
2 | //
3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 |
25 | #import
26 |
27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
28 |
29 | #import
30 |
31 | @class AFURLConnectionOperation;
32 |
33 | /**
34 | This category adds methods to the UIKit framework's `UIAlertView` class. The methods in this category provide support for automatically showing an alert if a session task or request operation finishes with an error. Alert title and message are filled from the corresponding `localizedDescription` & `localizedRecoverySuggestion` or `localizedFailureReason` of the error.
35 | */
36 | @interface UIAlertView (AFNetworking)
37 |
38 | ///-------------------------------------
39 | /// @name Showing Alert for Session Task
40 | ///-------------------------------------
41 |
42 | /**
43 | Shows an alert view with the error of the specified session task, if any.
44 |
45 | @param task The session task.
46 | @param delegate The alert view delegate.
47 | */
48 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
49 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task
50 | delegate:(id)delegate;
51 | #endif
52 |
53 | /**
54 | Shows an alert view with the error of the specified session task, if any, with a custom cancel button title and other button titles.
55 |
56 | @param task The session task.
57 | @param delegate The alert view delegate.
58 | @param cancelButtonTitle The title of the cancel button or nil if there is no cancel button. Using this argument is equivalent to setting the cancel button index to the value returned by invoking addButtonWithTitle: specifying this title.
59 | @param otherButtonTitles The title of another button. Using this argument is equivalent to invoking addButtonWithTitle: with this title to add more buttons. Too many buttons can cause the alert view to scroll. For guidelines on the best ways to use an alert in an app, see "Temporary Views". Titles of additional buttons to add to the receiver, terminated with `nil`.
60 | */
61 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
62 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task
63 | delegate:(id)delegate
64 | cancelButtonTitle:(NSString *)cancelButtonTitle
65 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION;
66 | #endif
67 |
68 | ///------------------------------------------
69 | /// @name Showing Alert for Request Operation
70 | ///------------------------------------------
71 |
72 | /**
73 | Shows an alert view with the error of the specified request operation, if any.
74 |
75 | @param operation The request operation.
76 | @param delegate The alert view delegate.
77 | */
78 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation
79 | delegate:(id)delegate;
80 |
81 | /**
82 | Shows an alert view with the error of the specified request operation, if any, with a custom cancel button title and other button titles.
83 |
84 | @param operation The request operation.
85 | @param delegate The alert view delegate.
86 | @param cancelButtonTitle The title of the cancel button or nil if there is no cancel button. Using this argument is equivalent to setting the cancel button index to the value returned by invoking addButtonWithTitle: specifying this title.
87 | @param otherButtonTitles The title of another button. Using this argument is equivalent to invoking addButtonWithTitle: with this title to add more buttons. Too many buttons can cause the alert view to scroll. For guidelines on the best ways to use an alert in an app, see "Temporary Views". Titles of additional buttons to add to the receiver, terminated with `nil`.
88 | */
89 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation
90 | delegate:(id)delegate
91 | cancelButtonTitle:(NSString *)cancelButtonTitle
92 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION;
93 |
94 | @end
95 |
96 | #endif
97 |
--------------------------------------------------------------------------------
/Demo/Pods/AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.m:
--------------------------------------------------------------------------------
1 | // UIAlertView+AFNetworking.m
2 | //
3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "UIAlertView+AFNetworking.h"
24 |
25 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
26 |
27 | #import "AFURLConnectionOperation.h"
28 |
29 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
30 | #import "AFURLSessionManager.h"
31 | #endif
32 |
33 | static void AFGetAlertViewTitleAndMessageFromError(NSError *error, NSString * __autoreleasing *title, NSString * __autoreleasing *message) {
34 | if (error.localizedDescription && (error.localizedRecoverySuggestion || error.localizedFailureReason)) {
35 | *title = error.localizedDescription;
36 |
37 | if (error.localizedRecoverySuggestion) {
38 | *message = error.localizedRecoverySuggestion;
39 | } else {
40 | *message = error.localizedFailureReason;
41 | }
42 | } else if (error.localizedDescription) {
43 | *title = NSLocalizedStringFromTable(@"Error", @"AFNetworking", @"Fallback Error Description");
44 | *message = error.localizedDescription;
45 | } else {
46 | *title = NSLocalizedStringFromTable(@"Error", @"AFNetworking", @"Fallback Error Description");
47 | *message = [NSString stringWithFormat:NSLocalizedStringFromTable(@"%@ Error: %d", @"AFNetworking", @"Fallback Error Failure Reason Format"), error.domain, error.code];
48 | }
49 | }
50 |
51 | @implementation UIAlertView (AFNetworking)
52 |
53 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
54 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task
55 | delegate:(id)delegate
56 | {
57 | [self showAlertViewForTaskWithErrorOnCompletion:task delegate:delegate cancelButtonTitle:NSLocalizedStringFromTable(@"Dismiss", @"AFNetworking", @"UIAlertView Cancel Button Title") otherButtonTitles:nil, nil];
58 | }
59 |
60 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task
61 | delegate:(id)delegate
62 | cancelButtonTitle:(NSString *)cancelButtonTitle
63 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION
64 | {
65 | __block id observer = [[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingTaskDidFinishNotification object:task queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) {
66 |
67 | NSError *error = notification.userInfo[AFNetworkingTaskDidFinishErrorKey];
68 | if (error) {
69 | NSString *title, *message;
70 | AFGetAlertViewTitleAndMessageFromError(error, &title, &message);
71 |
72 | [[[UIAlertView alloc] initWithTitle:title message:message delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:otherButtonTitles, nil] show];
73 | }
74 |
75 | [[NSNotificationCenter defaultCenter] removeObserver:observer name:AFNetworkingTaskDidFinishNotification object:notification.object];
76 | }];
77 | }
78 | #endif
79 |
80 | #pragma mark -
81 |
82 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation
83 | delegate:(id)delegate
84 | {
85 | [self showAlertViewForRequestOperationWithErrorOnCompletion:operation delegate:delegate cancelButtonTitle:NSLocalizedStringFromTable(@"Dismiss", @"AFNetworking", @"UIAlert View Cancel Button Title") otherButtonTitles:nil, nil];
86 | }
87 |
88 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation
89 | delegate:(id)delegate
90 | cancelButtonTitle:(NSString *)cancelButtonTitle
91 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION
92 | {
93 | __block id observer = [[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingOperationDidFinishNotification object:operation queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) {
94 |
95 | if (notification.object && [notification.object isKindOfClass:[AFURLConnectionOperation class]]) {
96 | NSError *error = [(AFURLConnectionOperation *)notification.object error];
97 | if (error) {
98 | NSString *title, *message;
99 | AFGetAlertViewTitleAndMessageFromError(error, &title, &message);
100 |
101 | [[[UIAlertView alloc] initWithTitle:title message:message delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:otherButtonTitles, nil] show];
102 | }
103 | }
104 |
105 | [[NSNotificationCenter defaultCenter] removeObserver:observer name:AFNetworkingOperationDidFinishNotification object:notification.object];
106 | }];
107 | }
108 |
109 | @end
110 |
111 | #endif
112 |
--------------------------------------------------------------------------------
/Demo/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIButton+AFNetworking.h
2 | //
3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 |
25 | #import
26 |
27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
28 |
29 | #import
30 |
31 | /**
32 | This category adds methods to the UIKit framework's `UIButton` class. The methods in this category provide support for loading remote images and background images asynchronously from a URL.
33 | */
34 | @interface UIButton (AFNetworking)
35 |
36 | ///--------------------
37 | /// @name Setting Image
38 | ///--------------------
39 |
40 | /**
41 | Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.
42 |
43 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
44 |
45 | @param state The control state.
46 | @param url The URL used for the image request.
47 | */
48 | - (void)setImageForState:(UIControlState)state
49 | withURL:(NSURL *)url;
50 |
51 | /**
52 | Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.
53 |
54 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
55 |
56 | @param state The control state.
57 | @param url The URL used for the image request.
58 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the button will not change its image until the image request finishes.
59 | */
60 | - (void)setImageForState:(UIControlState)state
61 | withURL:(NSURL *)url
62 | placeholderImage:(UIImage *)placeholderImage;
63 |
64 | /**
65 | Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.
66 |
67 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
68 |
69 | If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with `setImage:forState:` is applied.
70 |
71 | @param state The control state.
72 | @param urlRequest The URL request used for the image request.
73 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the button will not change its image until the image request finishes.
74 | @param success A block to be executed when the image request operation finishes successfully. This block has no return value and takes two arguments: the server response and the image. If the image was returned from cache, the request and response parameters will be `nil`.
75 | @param failure A block object to be executed when the image request operation finishes unsuccessfully, or that finishes successfully. This block has no return value and takes a single argument: the error that occurred.
76 | */
77 | - (void)setImageForState:(UIControlState)state
78 | withURLRequest:(NSURLRequest *)urlRequest
79 | placeholderImage:(UIImage *)placeholderImage
80 | success:(void (^)(NSHTTPURLResponse *response, UIImage *image))success
81 | failure:(void (^)(NSError *error))failure;
82 |
83 |
84 | ///-------------------------------
85 | /// @name Setting Background Image
86 | ///-------------------------------
87 |
88 | /**
89 | Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous background image request for the receiver will be cancelled.
90 |
91 | If the background image is cached locally, the background image is set immediately, otherwise the specified placeholder background image will be set immediately, and then the remote background image will be set once the request is finished.
92 |
93 | @param state The control state.
94 | @param url The URL used for the background image request.
95 | */
96 | - (void)setBackgroundImageForState:(UIControlState)state
97 | withURL:(NSURL *)url;
98 |
99 | /**
100 | Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.
101 |
102 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
103 |
104 | @param state The control state.
105 | @param url The URL used for the background image request.
106 | @param placeholderImage The background image to be set initially, until the background image request finishes. If `nil`, the button will not change its background image until the background image request finishes.
107 | */
108 | - (void)setBackgroundImageForState:(UIControlState)state
109 | withURL:(NSURL *)url
110 | placeholderImage:(UIImage *)placeholderImage;
111 |
112 | /**
113 | Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.
114 |
115 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
116 |
117 | If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with `setBackgroundImage:forState:` is applied.
118 |
119 | @param state The control state.
120 | @param urlRequest The URL request used for the image request.
121 | @param placeholderImage The background image to be set initially, until the background image request finishes. If `nil`, the button will not change its background image until the background image request finishes.
122 | */
123 | - (void)setBackgroundImageForState:(UIControlState)state
124 | withURLRequest:(NSURLRequest *)urlRequest
125 | placeholderImage:(UIImage *)placeholderImage
126 | success:(void (^)(NSHTTPURLResponse *response, UIImage *image))success
127 | failure:(void (^)(NSError *error))failure;
128 |
129 |
130 | ///------------------------------
131 | /// @name Canceling Image Loading
132 | ///------------------------------
133 |
134 | /**
135 | Cancels any executing image operation for the receiver, if one exists.
136 | */
137 | - (void)cancelImageRequestOperation;
138 |
139 | /**
140 | Cancels any executing background image operation for the receiver, if one exists.
141 | */
142 | - (void)cancelBackgroundImageRequestOperation;
143 |
144 | @end
145 |
146 | #endif
147 |
--------------------------------------------------------------------------------
/Demo/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.m:
--------------------------------------------------------------------------------
1 | // UIButton+AFNetworking.m
2 | //
3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "UIButton+AFNetworking.h"
24 |
25 | #import
26 |
27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
28 |
29 | #import "AFHTTPRequestOperation.h"
30 |
31 | static char kAFImageRequestOperationKey;
32 | static char kAFBackgroundImageRequestOperationKey;
33 |
34 | @interface UIButton (_AFNetworking)
35 | @property (readwrite, nonatomic, strong, setter = af_setImageRequestOperation:) AFHTTPRequestOperation *af_imageRequestOperation;
36 | @property (readwrite, nonatomic, strong, setter = af_setBackgroundImageRequestOperation:) AFHTTPRequestOperation *af_backgroundImageRequestOperation;
37 | @end
38 |
39 | @implementation UIButton (_AFNetworking)
40 |
41 | + (NSOperationQueue *)af_sharedImageRequestOperationQueue {
42 | static NSOperationQueue *_af_sharedImageRequestOperationQueue = nil;
43 | static dispatch_once_t onceToken;
44 | dispatch_once(&onceToken, ^{
45 | _af_sharedImageRequestOperationQueue = [[NSOperationQueue alloc] init];
46 | _af_sharedImageRequestOperationQueue.maxConcurrentOperationCount = NSOperationQueueDefaultMaxConcurrentOperationCount;
47 | });
48 |
49 | return _af_sharedImageRequestOperationQueue;
50 | }
51 |
52 | - (AFHTTPRequestOperation *)af_imageRequestOperation {
53 | return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, &kAFImageRequestOperationKey);
54 | }
55 |
56 | - (void)af_setImageRequestOperation:(AFHTTPRequestOperation *)imageRequestOperation {
57 | objc_setAssociatedObject(self, &kAFImageRequestOperationKey, imageRequestOperation, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
58 | }
59 |
60 | - (AFHTTPRequestOperation *)af_backgroundImageRequestOperation {
61 | return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, &kAFBackgroundImageRequestOperationKey);
62 | }
63 |
64 | - (void)af_setBackgroundImageRequestOperation:(AFHTTPRequestOperation *)imageRequestOperation {
65 | objc_setAssociatedObject(self, &kAFBackgroundImageRequestOperationKey, imageRequestOperation, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
66 | }
67 |
68 | @end
69 |
70 | #pragma mark -
71 |
72 | @implementation UIButton (AFNetworking)
73 |
74 | - (void)setImageForState:(UIControlState)state
75 | withURL:(NSURL *)url
76 | {
77 | [self setImageForState:state withURL:url placeholderImage:nil];
78 | }
79 |
80 | - (void)setImageForState:(UIControlState)state
81 | withURL:(NSURL *)url
82 | placeholderImage:(UIImage *)placeholderImage
83 | {
84 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
85 | [request addValue:@"image/*" forHTTPHeaderField:@"Accept"];
86 |
87 | [self setImageForState:state withURLRequest:request placeholderImage:placeholderImage success:nil failure:nil];
88 | }
89 |
90 | - (void)setImageForState:(UIControlState)state
91 | withURLRequest:(NSURLRequest *)urlRequest
92 | placeholderImage:(UIImage *)placeholderImage
93 | success:(void (^)(NSHTTPURLResponse *response, UIImage *image))success
94 | failure:(void (^)(NSError *error))failure
95 | {
96 | [self cancelImageRequestOperation];
97 |
98 | [self setImage:placeholderImage forState:state];
99 |
100 | __weak __typeof(self)weakSelf = self;
101 | self.af_imageRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest];
102 | self.af_imageRequestOperation.responseSerializer = [AFImageResponseSerializer serializer];
103 | [self.af_imageRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
104 | __strong __typeof(weakSelf)strongSelf = weakSelf;
105 | if ([[urlRequest URL] isEqual:[operation.request URL]]) {
106 | if (success) {
107 | success(operation.response, responseObject);
108 | } else if (responseObject) {
109 | [strongSelf setImage:responseObject forState:state];
110 | }
111 | } else {
112 |
113 | }
114 | } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
115 | if ([[urlRequest URL] isEqual:[operation.response URL]]) {
116 | if (failure) {
117 | failure(error);
118 | }
119 | }
120 | }];
121 |
122 | [[[self class] af_sharedImageRequestOperationQueue] addOperation:self.af_imageRequestOperation];
123 | }
124 |
125 | #pragma mark -
126 |
127 | - (void)setBackgroundImageForState:(UIControlState)state
128 | withURL:(NSURL *)url
129 | {
130 | [self setBackgroundImageForState:state withURL:url placeholderImage:nil];
131 | }
132 |
133 | - (void)setBackgroundImageForState:(UIControlState)state
134 | withURL:(NSURL *)url
135 | placeholderImage:(UIImage *)placeholderImage
136 | {
137 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
138 | [request addValue:@"image/*" forHTTPHeaderField:@"Accept"];
139 |
140 | [self setBackgroundImageForState:state withURLRequest:request placeholderImage:placeholderImage success:nil failure:nil];
141 | }
142 |
143 | - (void)setBackgroundImageForState:(UIControlState)state
144 | withURLRequest:(NSURLRequest *)urlRequest
145 | placeholderImage:(UIImage *)placeholderImage
146 | success:(void (^)(NSHTTPURLResponse *response, UIImage *image))success
147 | failure:(void (^)(NSError *error))failure
148 | {
149 | [self cancelBackgroundImageRequestOperation];
150 |
151 | [self setBackgroundImage:placeholderImage forState:state];
152 |
153 | __weak __typeof(self)weakSelf = self;
154 | self.af_backgroundImageRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest];
155 | self.af_backgroundImageRequestOperation.responseSerializer = [AFImageResponseSerializer serializer];
156 | [self.af_backgroundImageRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
157 | __strong __typeof(weakSelf)strongSelf = weakSelf;
158 | if ([[urlRequest URL] isEqual:[operation.request URL]]) {
159 | if (success) {
160 | success(operation.response, responseObject);
161 | } else if (responseObject) {
162 | [strongSelf setBackgroundImage:responseObject forState:state];
163 | }
164 | } else {
165 |
166 | }
167 | } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
168 | if ([[urlRequest URL] isEqual:[operation.response URL]]) {
169 | if (failure) {
170 | failure(error);
171 | }
172 | }
173 | }];
174 |
175 | [[[self class] af_sharedImageRequestOperationQueue] addOperation:self.af_backgroundImageRequestOperation];
176 | }
177 |
178 | #pragma mark -
179 |
180 | - (void)cancelImageRequestOperation {
181 | [self.af_imageRequestOperation cancel];
182 | self.af_imageRequestOperation = nil;
183 | }
184 |
185 | - (void)cancelBackgroundImageRequestOperation {
186 | [self.af_backgroundImageRequestOperation cancel];
187 | self.af_backgroundImageRequestOperation = nil;
188 | }
189 |
190 | @end
191 |
192 | #endif
193 |
--------------------------------------------------------------------------------
/Demo/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIImageView+AFNetworking.h
2 | //
3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 |
25 | #import
26 |
27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
28 |
29 | #import
30 |
31 | #import "AFURLResponseSerialization.h"
32 |
33 | /**
34 | This category adds methods to the UIKit framework's `UIImageView` class. The methods in this category provide support for loading remote images asynchronously from a URL.
35 | */
36 | @interface UIImageView (AFNetworking)
37 |
38 | ///------------------------------------
39 | /// @name Accessing Response Serializer
40 | ///------------------------------------
41 |
42 | /**
43 | The response serializer used to create an image representation from the server response and response data. By default, this is an instance of `AFImageResponseSerializer`.
44 |
45 | @discussion Subclasses of `AFImageResponseSerializer` could be used to perform post-processing, such as color correction, face detection, or other effects. See https://github.com/AFNetworking/AFCoreImageSerializer
46 | */
47 | @property (nonatomic, strong) AFImageResponseSerializer * imageResponseSerializer;
48 |
49 | ///--------------------
50 | /// @name Setting Image
51 | ///--------------------
52 |
53 | /**
54 | Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled.
55 |
56 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
57 |
58 | By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:`
59 |
60 | @param url The URL used for the image request.
61 | */
62 | - (void)setImageWithURL:(NSURL *)url;
63 |
64 | /**
65 | Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled.
66 |
67 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
68 |
69 | By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:`
70 |
71 | @param url The URL used for the image request.
72 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes.
73 | */
74 | - (void)setImageWithURL:(NSURL *)url
75 | placeholderImage:(UIImage *)placeholderImage;
76 |
77 | /**
78 | Asynchronously downloads an image from the specified URL request, and sets it once the request is finished. Any previous image request for the receiver will be cancelled.
79 |
80 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
81 |
82 | If a success block is specified, it is the responsibility of the block to set the image of the image view before returning. If no success block is specified, the default behavior of setting the image with `self.image = image` is applied.
83 |
84 | @param urlRequest The URL request used for the image request.
85 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes.
86 | @param success A block to be executed when the image request operation finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the request and response parameters will be `nil`.
87 | @param failure A block object to be executed when the image request operation finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.
88 | */
89 | - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
90 | placeholderImage:(UIImage *)placeholderImage
91 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
92 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure;
93 |
94 | /**
95 | Cancels any executing image operation for the receiver, if one exists.
96 | */
97 | - (void)cancelImageRequestOperation;
98 |
99 | @end
100 |
101 | #endif
102 |
--------------------------------------------------------------------------------
/Demo/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.m:
--------------------------------------------------------------------------------
1 | // UIImageView+AFNetworking.m
2 | //
3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "UIImageView+AFNetworking.h"
24 |
25 | #import
26 |
27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
28 |
29 | #import "AFHTTPRequestOperation.h"
30 |
31 | @interface AFImageCache : NSCache
32 | - (UIImage *)cachedImageForRequest:(NSURLRequest *)request;
33 | - (void)cacheImage:(UIImage *)image
34 | forRequest:(NSURLRequest *)request;
35 | @end
36 |
37 | #pragma mark -
38 |
39 | static char kAFImageRequestOperationKey;
40 | static char kAFResponseSerializerKey;
41 |
42 | @interface UIImageView (_AFNetworking)
43 | @property (readwrite, nonatomic, strong, setter = af_setImageRequestOperation:) AFHTTPRequestOperation *af_imageRequestOperation;
44 | @end
45 |
46 | @implementation UIImageView (_AFNetworking)
47 |
48 | + (NSOperationQueue *)af_sharedImageRequestOperationQueue {
49 | static NSOperationQueue *_af_sharedImageRequestOperationQueue = nil;
50 | static dispatch_once_t onceToken;
51 | dispatch_once(&onceToken, ^{
52 | _af_sharedImageRequestOperationQueue = [[NSOperationQueue alloc] init];
53 | _af_sharedImageRequestOperationQueue.maxConcurrentOperationCount = NSOperationQueueDefaultMaxConcurrentOperationCount;
54 | });
55 |
56 | return _af_sharedImageRequestOperationQueue;
57 | }
58 |
59 | + (AFImageCache *)af_sharedImageCache {
60 | static AFImageCache *_af_imageCache = nil;
61 | static dispatch_once_t oncePredicate;
62 | dispatch_once(&oncePredicate, ^{
63 | _af_imageCache = [[AFImageCache alloc] init];
64 |
65 | [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidReceiveMemoryWarningNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * __unused notification) {
66 | [_af_imageCache removeAllObjects];
67 | }];
68 | });
69 |
70 | return _af_imageCache;
71 | }
72 |
73 | - (AFHTTPRequestOperation *)af_imageRequestOperation {
74 | return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, &kAFImageRequestOperationKey);
75 | }
76 |
77 | - (void)af_setImageRequestOperation:(AFHTTPRequestOperation *)imageRequestOperation {
78 | objc_setAssociatedObject(self, &kAFImageRequestOperationKey, imageRequestOperation, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
79 | }
80 |
81 | @end
82 |
83 | #pragma mark -
84 |
85 | @implementation UIImageView (AFNetworking)
86 | @dynamic imageResponseSerializer;
87 |
88 | - (id )imageResponseSerializer {
89 | static id _af_defaultImageResponseSerializer = nil;
90 | static dispatch_once_t onceToken;
91 | dispatch_once(&onceToken, ^{
92 | _af_defaultImageResponseSerializer = [AFImageResponseSerializer serializer];
93 | });
94 |
95 | #pragma clang diagnostic push
96 | #pragma clang diagnostic ignored "-Wgnu"
97 | return objc_getAssociatedObject(self, &kAFResponseSerializerKey) ?: _af_defaultImageResponseSerializer;
98 | #pragma clang diagnostic pop
99 | }
100 |
101 | - (void)setImageResponseSerializer:(id )serializer {
102 | objc_setAssociatedObject(self, &kAFResponseSerializerKey, serializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
103 | }
104 |
105 | #pragma mark -
106 |
107 | - (void)setImageWithURL:(NSURL *)url {
108 | [self setImageWithURL:url placeholderImage:nil];
109 | }
110 |
111 | - (void)setImageWithURL:(NSURL *)url
112 | placeholderImage:(UIImage *)placeholderImage
113 | {
114 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
115 | [request addValue:@"image/*" forHTTPHeaderField:@"Accept"];
116 |
117 | [self setImageWithURLRequest:request placeholderImage:placeholderImage success:nil failure:nil];
118 | }
119 |
120 | - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
121 | placeholderImage:(UIImage *)placeholderImage
122 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
123 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure
124 | {
125 | [self cancelImageRequestOperation];
126 |
127 | UIImage *cachedImage = [[[self class] af_sharedImageCache] cachedImageForRequest:urlRequest];
128 | if (cachedImage) {
129 | if (success) {
130 | success(nil, nil, cachedImage);
131 | } else {
132 | self.image = cachedImage;
133 | }
134 |
135 | self.af_imageRequestOperation = nil;
136 | } else {
137 | self.image = placeholderImage;
138 |
139 | __weak __typeof(self)weakSelf = self;
140 | self.af_imageRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest];
141 | self.af_imageRequestOperation.responseSerializer = self.imageResponseSerializer;
142 | [self.af_imageRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
143 | __strong __typeof(weakSelf)strongSelf = weakSelf;
144 | if ([[urlRequest URL] isEqual:[operation.request URL]]) {
145 | if (success) {
146 | success(urlRequest, operation.response, responseObject);
147 | } else if (responseObject) {
148 | strongSelf.image = responseObject;
149 | }
150 | }
151 |
152 | [[[strongSelf class] af_sharedImageCache] cacheImage:responseObject forRequest:urlRequest];
153 | } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
154 | if ([[urlRequest URL] isEqual:[operation.request URL]]) {
155 | if (failure) {
156 | failure(urlRequest, operation.response, error);
157 | }
158 | }
159 | }];
160 |
161 | [[[self class] af_sharedImageRequestOperationQueue] addOperation:self.af_imageRequestOperation];
162 | }
163 | }
164 |
165 | - (void)cancelImageRequestOperation {
166 | [self.af_imageRequestOperation cancel];
167 | self.af_imageRequestOperation = nil;
168 | }
169 |
170 | @end
171 |
172 | #pragma mark -
173 |
174 | static inline NSString * AFImageCacheKeyFromURLRequest(NSURLRequest *request) {
175 | return [[request URL] absoluteString];
176 | }
177 |
178 | @implementation AFImageCache
179 |
180 | - (UIImage *)cachedImageForRequest:(NSURLRequest *)request {
181 | switch ([request cachePolicy]) {
182 | case NSURLRequestReloadIgnoringCacheData:
183 | case NSURLRequestReloadIgnoringLocalAndRemoteCacheData:
184 | return nil;
185 | default:
186 | break;
187 | }
188 |
189 | return [self objectForKey:AFImageCacheKeyFromURLRequest(request)];
190 | }
191 |
192 | - (void)cacheImage:(UIImage *)image
193 | forRequest:(NSURLRequest *)request
194 | {
195 | if (image && request) {
196 | [self setObject:image forKey:AFImageCacheKeyFromURLRequest(request)];
197 | }
198 | }
199 |
200 | @end
201 |
202 | #endif
203 |
--------------------------------------------------------------------------------
/Demo/Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIKit+AFNetworking.h
2 | //
3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com/)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 |
25 | #ifndef _UIKIT_AFNETWORKING_
26 | #define _UIKIT_AFNETWORKING_
27 |
28 | #import "AFNetworkActivityIndicatorManager.h"
29 |
30 | #import "UIActivityIndicatorView+AFNetworking.h"
31 | #import "UIAlertView+AFNetworking.h"
32 | #import "UIButton+AFNetworking.h"
33 | #import "UIImageView+AFNetworking.h"
34 | #import "UIKit+AFNetworking.h"
35 | #import "UIProgressView+AFNetworking.h"
36 | #import "UIWebView+AFNetworking.h"
37 | #endif /* _UIKIT_AFNETWORKING_ */
38 |
--------------------------------------------------------------------------------
/Demo/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIProgressView+AFNetworking.h
2 | //
3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 |
25 | #import
26 |
27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
28 |
29 | #import
30 |
31 | @class AFURLConnectionOperation;
32 |
33 | /**
34 | This category adds methods to the UIKit framework's `UIProgressView` class. The methods in this category provide support for binding the progress to the upload and download progress of a session task or request operation.
35 | */
36 | @interface UIProgressView (AFNetworking)
37 |
38 | ///------------------------------------
39 | /// @name Setting Session Task Progress
40 | ///------------------------------------
41 |
42 | /**
43 | Binds the progress to the upload progress of the specified session task.
44 |
45 | @param task The session task.
46 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately.
47 | */
48 | #if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090)
49 | - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task
50 | animated:(BOOL)animated;
51 | #endif
52 |
53 | /**
54 | Binds the progress to the download progress of the specified session task.
55 |
56 | @param task The session task.
57 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately.
58 | */
59 | #if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090)
60 | - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task
61 | animated:(BOOL)animated;
62 | #endif
63 |
64 | ///------------------------------------
65 | /// @name Setting Session Task Progress
66 | ///------------------------------------
67 |
68 | /**
69 | Binds the progress to the upload progress of the specified request operation.
70 |
71 | @param operation The request operation.
72 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately.
73 | */
74 | - (void)setProgressWithUploadProgressOfOperation:(AFURLConnectionOperation *)operation
75 | animated:(BOOL)animated;
76 |
77 | /**
78 | Binds the progress to the download progress of the specified request operation.
79 |
80 | @param operation The request operation.
81 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately.
82 | */
83 | - (void)setProgressWithDownloadProgressOfOperation:(AFURLConnectionOperation *)operation
84 | animated:(BOOL)animated;
85 |
86 | @end
87 |
88 | #endif
89 |
--------------------------------------------------------------------------------
/Demo/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m:
--------------------------------------------------------------------------------
1 | // UIProgressView+AFNetworking.m
2 | //
3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "UIProgressView+AFNetworking.h"
24 |
25 | #import
26 |
27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
28 |
29 | #import "AFURLConnectionOperation.h"
30 |
31 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
32 | #import "AFURLSessionManager.h"
33 | #endif
34 |
35 | static void * AFTaskCountOfBytesSentContext = &AFTaskCountOfBytesSentContext;
36 | static void * AFTaskCountOfBytesReceivedContext = &AFTaskCountOfBytesReceivedContext;
37 |
38 | static char kAFUploadProgressAnimated;
39 | static char kAFDownloadProgressAnimated;
40 |
41 | @interface AFURLConnectionOperation (_UIProgressView)
42 | @property (readwrite, nonatomic, copy) void (^uploadProgress)(NSUInteger bytes, long long totalBytes, long long totalBytesExpected);
43 | @property (readwrite, nonatomic, assign, setter = af_setUploadProgressAnimated:) BOOL af_uploadProgressAnimated;
44 |
45 | @property (readwrite, nonatomic, copy) void (^downloadProgress)(NSUInteger bytes, long long totalBytes, long long totalBytesExpected);
46 | @property (readwrite, nonatomic, assign, setter = af_setDownloadProgressAnimated:) BOOL af_downloadProgressAnimated;
47 | @end
48 |
49 | @implementation AFURLConnectionOperation (_UIProgressView)
50 | @dynamic uploadProgress; // Implemented in AFURLConnectionOperation
51 | @dynamic af_uploadProgressAnimated;
52 |
53 | @dynamic downloadProgress; // Implemented in AFURLConnectionOperation
54 | @dynamic af_downloadProgressAnimated;
55 | @end
56 |
57 | #pragma mark -
58 |
59 | @implementation UIProgressView (AFNetworking)
60 |
61 | - (BOOL)af_uploadProgressAnimated {
62 | return [(NSNumber *)objc_getAssociatedObject(self, &kAFUploadProgressAnimated) boolValue];
63 | }
64 |
65 | - (void)af_setUploadProgressAnimated:(BOOL)animated {
66 | objc_setAssociatedObject(self, &kAFUploadProgressAnimated, @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
67 | }
68 |
69 | - (BOOL)af_downloadProgressAnimated {
70 | return [(NSNumber *)objc_getAssociatedObject(self, &kAFDownloadProgressAnimated) boolValue];
71 | }
72 |
73 | - (void)af_setDownloadProgressAnimated:(BOOL)animated {
74 | objc_setAssociatedObject(self, &kAFDownloadProgressAnimated, @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
75 | }
76 |
77 | #pragma mark -
78 |
79 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
80 |
81 | - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task
82 | animated:(BOOL)animated
83 | {
84 | [task addObserver:self forKeyPath:@"state" options:0 context:AFTaskCountOfBytesSentContext];
85 | [task addObserver:self forKeyPath:@"countOfBytesSent" options:0 context:AFTaskCountOfBytesSentContext];
86 |
87 | [self af_setUploadProgressAnimated:animated];
88 | }
89 |
90 | - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task
91 | animated:(BOOL)animated
92 | {
93 | [task addObserver:self forKeyPath:@"state" options:0 context:AFTaskCountOfBytesReceivedContext];
94 | [task addObserver:self forKeyPath:@"countOfBytesReceived" options:0 context:AFTaskCountOfBytesReceivedContext];
95 |
96 | [self af_setDownloadProgressAnimated:animated];
97 | }
98 |
99 | #endif
100 |
101 | #pragma mark -
102 |
103 | - (void)setProgressWithUploadProgressOfOperation:(AFURLConnectionOperation *)operation
104 | animated:(BOOL)animated
105 | {
106 | __weak __typeof(self)weakSelf = self;
107 | void (^original)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) = [operation.uploadProgress copy];
108 | [operation setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {
109 | if (original) {
110 | original(bytesWritten, totalBytesWritten, totalBytesExpectedToWrite);
111 | }
112 |
113 | dispatch_async(dispatch_get_main_queue(), ^{
114 | if (totalBytesExpectedToWrite > 0) {
115 | [weakSelf setProgress:(totalBytesWritten / (totalBytesExpectedToWrite * 1.0f)) animated:animated];
116 | }
117 | });
118 | }];
119 | }
120 |
121 | - (void)setProgressWithDownloadProgressOfOperation:(AFURLConnectionOperation *)operation
122 | animated:(BOOL)animated
123 | {
124 | __weak __typeof(self)weakSelf = self;
125 | void (^original)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) = [operation.downloadProgress copy];
126 | [operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
127 | if (original) {
128 | original(bytesRead, totalBytesRead, totalBytesExpectedToRead);
129 | }
130 |
131 | dispatch_async(dispatch_get_main_queue(), ^{
132 | if (totalBytesExpectedToRead > 0) {
133 | [weakSelf setProgress:(totalBytesRead / (totalBytesExpectedToRead * 1.0f)) animated:animated];
134 | }
135 | });
136 | }];
137 | }
138 |
139 | #pragma mark - NSKeyValueObserving
140 |
141 | - (void)observeValueForKeyPath:(NSString *)keyPath
142 | ofObject:(id)object
143 | change:(__unused NSDictionary *)change
144 | context:(void *)context
145 | {
146 | #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000
147 | if (context == AFTaskCountOfBytesSentContext || context == AFTaskCountOfBytesReceivedContext) {
148 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesSent))]) {
149 | if ([object countOfBytesExpectedToSend] > 0) {
150 | dispatch_async(dispatch_get_main_queue(), ^{
151 | [self setProgress:[object countOfBytesSent] / ([object countOfBytesExpectedToSend] * 1.0f) animated:self.af_uploadProgressAnimated];
152 | });
153 | }
154 | }
155 |
156 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesReceived))]) {
157 | if ([object countOfBytesExpectedToReceive] > 0) {
158 | dispatch_async(dispatch_get_main_queue(), ^{
159 | [self setProgress:[object countOfBytesReceived] / ([object countOfBytesExpectedToReceive] * 1.0f) animated:self.af_downloadProgressAnimated];
160 | });
161 | }
162 | }
163 |
164 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(state))]) {
165 | if ([(NSURLSessionTask *)object state] == NSURLSessionTaskStateCompleted) {
166 | @try {
167 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(state))];
168 |
169 | if (context == AFTaskCountOfBytesSentContext) {
170 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesSent))];
171 | }
172 |
173 | if (context == AFTaskCountOfBytesReceivedContext) {
174 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesReceived))];
175 | }
176 | }
177 | @catch (NSException * __unused exception) {}
178 | }
179 | }
180 | }
181 | #endif
182 | }
183 |
184 | @end
185 |
186 | #endif
187 |
--------------------------------------------------------------------------------
/Demo/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIWebView+AFNetworking.h
2 | //
3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 |
25 | #import
26 |
27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
28 |
29 | #import
30 |
31 | #import "AFURLRequestSerialization.h"
32 | #import "AFURLResponseSerialization.h"
33 |
34 | /**
35 | This category adds methods to the UIKit framework's `UIWebView` class. The methods in this category provide increased control over the request cycle, including progress monitoring and success / failure handling.
36 | */
37 | @interface UIWebView (AFNetworking)
38 |
39 | /**
40 | The request serializer used to serialize requests made with the `-loadRequest:...` category methods. By default, this is an instance of `AFHTTPRequestSerializer`.
41 | */
42 | @property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer;
43 |
44 | /**
45 | The response serializer used to serialize responses made with the `-loadRequest:...` category methods. By default, this is an instance of `AFHTTPResponseSerializer`.
46 | */
47 | @property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer;
48 |
49 | /**
50 | Asynchronously loads the specified request.
51 |
52 | @param request A URL request identifying the location of the content to load. This must not be `nil`.
53 | @param progress A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the main thread.
54 | @param success A block object to be executed when the request finishes loading successfully. This block returns the HTML string to be loaded by the web view, and takes two arguments: the response, and the response string.
55 | @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred.
56 | */
57 | - (void)loadRequest:(NSURLRequest *)request
58 | progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress
59 | success:(NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success
60 | failure:(void (^)(NSError *error))failure;
61 |
62 | /**
63 | Asynchronously loads the data associated with a particular request with a specified MIME type and text encoding.
64 |
65 | @param request A URL request identifying the location of the content to load. This must not be `nil`.
66 | @param MIMEType The MIME type of the content. Defaults to the content type of the response if not specified.
67 | @param textEncodingName The IANA encoding name, as in `utf-8` or `utf-16`. Defaults to the response text encoding if not specified.
68 | @param progress A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the main thread.
69 | @param success A block object to be executed when the request finishes loading successfully. This block returns the data to be loaded by the web view and takes two arguments: the response, and the downloaded data.
70 | @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred.
71 | */
72 | - (void)loadRequest:(NSURLRequest *)request
73 | MIMEType:(NSString *)MIMEType
74 | textEncodingName:(NSString *)textEncodingName
75 | progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress
76 | success:(NSData * (^)(NSHTTPURLResponse *response, NSData *data))success
77 | failure:(void (^)(NSError *error))failure;
78 |
79 | @end
80 |
81 | #endif
82 |
--------------------------------------------------------------------------------
/Demo/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m:
--------------------------------------------------------------------------------
1 | // UIWebView+AFNetworking.m
2 | //
3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "UIWebView+AFNetworking.h"
24 |
25 | #import
26 |
27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
28 |
29 | #import "AFHTTPRequestOperation.h"
30 |
31 | static char kAFRequestSerializerKey;
32 | static char kAFResponseSerializerKey;
33 | static char kAFHTTPRequestOperationKey;
34 |
35 | @interface UIWebView (_AFNetworking)
36 | @property (readwrite, nonatomic, strong, setter = af_setHTTPRequestOperation:) AFHTTPRequestOperation *af_HTTPRequestOperation;
37 | @end
38 |
39 | @implementation UIWebView (_AFNetworking)
40 |
41 | - (AFHTTPRequestOperation *)af_HTTPRequestOperation {
42 | return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, &kAFHTTPRequestOperationKey);
43 | }
44 |
45 | - (void)af_setHTTPRequestOperation:(AFHTTPRequestOperation *)operation {
46 | objc_setAssociatedObject(self, &kAFHTTPRequestOperationKey, operation, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
47 | }
48 |
49 | @end
50 |
51 | #pragma mark -
52 |
53 | @implementation UIWebView (AFNetworking)
54 |
55 | - (AFHTTPRequestSerializer *)requestSerializer {
56 | static AFHTTPRequestSerializer * _af_defaultRequestSerializer = nil;
57 | static dispatch_once_t onceToken;
58 | dispatch_once(&onceToken, ^{
59 | _af_defaultRequestSerializer = [AFHTTPRequestSerializer serializer];
60 | });
61 |
62 | #pragma clang diagnostic push
63 | #pragma clang diagnostic ignored "-Wgnu"
64 | return objc_getAssociatedObject(self, &kAFRequestSerializerKey) ?: _af_defaultRequestSerializer;
65 | #pragma clang diagnostic pop
66 | }
67 |
68 | - (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer {
69 | objc_setAssociatedObject(self, &kAFRequestSerializerKey, requestSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
70 | }
71 |
72 | - (AFHTTPResponseSerializer *)responseSerializer {
73 | static AFHTTPResponseSerializer * _af_defaultResponseSerializer = nil;
74 | static dispatch_once_t onceToken;
75 | dispatch_once(&onceToken, ^{
76 | _af_defaultResponseSerializer = [AFHTTPResponseSerializer serializer];
77 | });
78 |
79 | #pragma clang diagnostic push
80 | #pragma clang diagnostic ignored "-Wgnu"
81 | return objc_getAssociatedObject(self, &kAFRequestSerializerKey) ?: _af_defaultResponseSerializer;
82 | #pragma clang diagnostic pop
83 | }
84 |
85 | - (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer {
86 | objc_setAssociatedObject(self, &kAFResponseSerializerKey, responseSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
87 | }
88 |
89 | #pragma mark -
90 |
91 | - (void)loadRequest:(NSURLRequest *)request
92 | progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress
93 | success:(NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success
94 | failure:(void (^)(NSError *error))failure
95 | {
96 | [self loadRequest:request MIMEType:nil textEncodingName:nil progress:progress success:^NSData *(NSHTTPURLResponse *response, NSData *data) {
97 | if (!success) {
98 | return data;
99 | }
100 |
101 | NSStringEncoding stringEncoding = NSUTF8StringEncoding;
102 | if (response.textEncodingName) {
103 | CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName);
104 | if (encoding != kCFStringEncodingInvalidId) {
105 | stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding);
106 | }
107 | }
108 |
109 | return [[[NSString alloc] initWithData:data encoding:stringEncoding] dataUsingEncoding:stringEncoding];
110 | } failure:failure];
111 | }
112 |
113 | - (void)loadRequest:(NSURLRequest *)request
114 | MIMEType:(NSString *)MIMEType
115 | textEncodingName:(NSString *)textEncodingName
116 | progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress
117 | success:(NSData * (^)(NSHTTPURLResponse *response, NSData *data))success
118 | failure:(void (^)(NSError *error))failure
119 | {
120 | NSParameterAssert(request);
121 |
122 | if (self.af_HTTPRequestOperation) {
123 | [self.af_HTTPRequestOperation cancel];
124 | }
125 |
126 | request = [self.requestSerializer requestBySerializingRequest:request withParameters:nil error:nil];
127 |
128 | self.af_HTTPRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
129 | self.af_HTTPRequestOperation.responseSerializer = self.responseSerializer;
130 |
131 | __weak __typeof(self)weakSelf = self;
132 | [self.af_HTTPRequestOperation setDownloadProgressBlock:progress];
133 | [self.af_HTTPRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id __unused responseObject) {
134 | NSData *data = success ? success(operation.response, operation.responseData) : operation.responseData;
135 |
136 | #pragma clang diagnostic push
137 | #pragma clang diagnostic ignored "-Wgnu"
138 | [weakSelf loadData:data MIMEType:(MIMEType ?: [operation.response MIMEType]) textEncodingName:(textEncodingName ?: [operation.response textEncodingName]) baseURL:[operation.response URL]];
139 | #pragma clang diagnostic pop
140 | } failure:^(AFHTTPRequestOperation * __unused operation, NSError *error) {
141 | if (failure) {
142 | failure(error);
143 | }
144 | }];
145 |
146 | [self.af_HTTPRequestOperation start];
147 | }
148 |
149 | @end
150 |
151 | #endif
152 |
--------------------------------------------------------------------------------
/Demo/Pods/BuildHeaders/AFNetworking/AFHTTPRequestOperation.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/AFNetworking/AFHTTPRequestOperation.h
--------------------------------------------------------------------------------
/Demo/Pods/BuildHeaders/AFNetworking/AFHTTPRequestOperationManager.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/AFNetworking/AFHTTPRequestOperationManager.h
--------------------------------------------------------------------------------
/Demo/Pods/BuildHeaders/AFNetworking/AFHTTPSessionManager.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/AFNetworking/AFHTTPSessionManager.h
--------------------------------------------------------------------------------
/Demo/Pods/BuildHeaders/AFNetworking/AFNetworkActivityIndicatorManager.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h
--------------------------------------------------------------------------------
/Demo/Pods/BuildHeaders/AFNetworking/AFNetworkReachabilityManager.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h
--------------------------------------------------------------------------------
/Demo/Pods/BuildHeaders/AFNetworking/AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/AFNetworking/AFNetworking.h
--------------------------------------------------------------------------------
/Demo/Pods/BuildHeaders/AFNetworking/AFSecurityPolicy.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/AFNetworking/AFSecurityPolicy.h
--------------------------------------------------------------------------------
/Demo/Pods/BuildHeaders/AFNetworking/AFURLConnectionOperation.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/AFNetworking/AFURLConnectionOperation.h
--------------------------------------------------------------------------------
/Demo/Pods/BuildHeaders/AFNetworking/AFURLRequestSerialization.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/AFNetworking/AFURLRequestSerialization.h
--------------------------------------------------------------------------------
/Demo/Pods/BuildHeaders/AFNetworking/AFURLResponseSerialization.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/AFNetworking/AFURLResponseSerialization.h
--------------------------------------------------------------------------------
/Demo/Pods/BuildHeaders/AFNetworking/AFURLSessionManager.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/AFNetworking/AFURLSessionManager.h
--------------------------------------------------------------------------------
/Demo/Pods/BuildHeaders/AFNetworking/UIActivityIndicatorView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h
--------------------------------------------------------------------------------
/Demo/Pods/BuildHeaders/AFNetworking/UIAlertView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h
--------------------------------------------------------------------------------
/Demo/Pods/BuildHeaders/AFNetworking/UIButton+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h
--------------------------------------------------------------------------------
/Demo/Pods/BuildHeaders/AFNetworking/UIImageView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h
--------------------------------------------------------------------------------
/Demo/Pods/BuildHeaders/AFNetworking/UIKit+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h
--------------------------------------------------------------------------------
/Demo/Pods/BuildHeaders/AFNetworking/UIProgressView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h
--------------------------------------------------------------------------------
/Demo/Pods/BuildHeaders/AFNetworking/UIWebView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h
--------------------------------------------------------------------------------
/Demo/Pods/BuildHeaders/CMDataStorage/CMDataStorage.h:
--------------------------------------------------------------------------------
1 | ../../CMDataStorage/CMDataStorage/CMDataStorage.h
--------------------------------------------------------------------------------
/Demo/Pods/CMDataStorage/CMDataStorage/CMDataStorage.h:
--------------------------------------------------------------------------------
1 | //
2 | // CMDataStorage.h
3 | //
4 | // Created by Constantine Mureev on 16.02.12.
5 | // Copyright (c) 2012 Team Force LLC. All rights reserved.
6 | //
7 |
8 | #import
9 | #import
10 |
11 | // Safe file naming using MD5. Remove this define if you want use key as file name.
12 | #define MD5_FOR_KEY
13 |
14 | @interface CMDataStorage : NSObject
15 |
16 | + (instancetype)sharedCacheStorage;
17 | + (instancetype)sharedDocumentsStorage;
18 | + (instancetype)sharedTemporaryStorage;
19 |
20 | /**
21 | Asynchronously writes data to the specified storage.
22 |
23 | Asynchronously call write on separeated GCD queue with key as file name (or MD5 of key). After it writes the data, the method will call block if it specified.
24 |
25 | @param data The data to be written. Required.
26 | @param key The string that will used as file name. Or MD5 of key if MD5_FOR_KEY define exist. Required.
27 | @param block Complition block with result BOOL value. Optional.
28 | */
29 | - (void)writeData:(NSData *)data key:(NSString *)key block:(void (^)(BOOL succeeds))block;
30 |
31 | /**
32 | Asynchronously reads data from the specified storage / key.
33 |
34 | Asynchronously call read on separeated GCD queue with key as file name (or MD5 of key). After it reads the data, the method will call block. If any error occured or there is no file for that key than the data in complition block will be nil.
35 |
36 | @param key The string that will used as file name. Or MD5 of key if MD5_FOR_KEY define exist. Required.
37 | @param block Complition block with result NSData value. Required.
38 | */
39 | - (void)dataForKey:(NSString *)key block:(void (^)(NSData *data))block;
40 |
41 | /**
42 | Asynchronously remove data to the specified storage / key.
43 |
44 | Asynchronously call delete on separeated GCD queue with key as file name (or MD5 of key). After it writes the data, the method will call block if it specified.
45 |
46 | @param key The string that will used as file name. Or MD5 of key if MD5_FOR_KEY define exist. Required.
47 | @param block Complition block with result BOOL value. Optional.
48 | */
49 | - (void)removeDataForKey:(NSString *)key block:(void (^)(BOOL succeeds))block;
50 |
51 | /**
52 | Synchronously writes data to the specified storage / key.
53 |
54 | Writes the data to the file specified by a given key for current storage.
55 |
56 | @param data The data to be written. Required.
57 | @param key The string that will used as file name. Or MD5 of key if MD5_FOR_KEY define exist. Required.
58 |
59 | @return YES if the operation succeeds, otherwise NO.
60 | */
61 | - (BOOL)writeData:(NSData *)data key:(NSString *)key;
62 |
63 |
64 | /**
65 | Synchronously reads data from the specified storage / key.
66 |
67 | Creates and returns a data object by reading every byte from the file specified by a given key in current storage. Without using GCD queue.
68 |
69 | @param key The string that will used as file name. Or MD5 of key if MD5_FOR_KEY define exist. Required.
70 |
71 | @return A data object by reading every byte from the file specified by key. Returns nil if the data object could not be created.
72 | */
73 | - (NSData *)dataForKey:(NSString *)key;
74 |
75 | /**
76 | Returns whether the cached data pointed to by a key can be reached.
77 |
78 | This method synchronously checks if the data at the provided key is cached. Checking reachability is appropriate when making decisions that do not require other immediate operations on the resource, such as periodic maintenance of user interface state that depends on the existence of a specific document. For example, you might remove an item from a download list if the user deletes the file.
79 |
80 | @param key The string that will used as file name. Or MD5 of key if MD5_FOR_KEY define exist. Required.
81 |
82 | @return YES if the data is cached; otherwise, NO.
83 | */
84 | - (BOOL)isStored:(NSString *)key;
85 |
86 | /**
87 | Returns a file reference URL that points to the original file by key in current storage.
88 |
89 | This method just create NSURL object without checking it reachability.
90 |
91 | @param key The string that will used as file name. Or MD5 of key if MD5_FOR_KEY define exist. Required.
92 |
93 | @return The NSURL object with path to file.
94 | */
95 | - (NSURL *)fileURLWithKey:(NSString *)key;
96 |
97 | /**
98 | Returns a file reference path that points to the original file by key in current storage.
99 |
100 | This method just create NSString object without checking it reachability.
101 |
102 | @param key The string that will used as file name. Or MD5 of key if MD5_FOR_KEY define exist. Required.
103 |
104 | @return The NSString object with file path.
105 | */
106 | - (NSString *)filePathWithKey:(NSString *)key;
107 |
108 | @end
109 |
--------------------------------------------------------------------------------
/Demo/Pods/CMDataStorage/CMDataStorage/CMDataStorage.m:
--------------------------------------------------------------------------------
1 | //
2 | // CMDataStorage.m
3 | //
4 | // Created by Constantine Mureev on 16.02.12.
5 | // Copyright (c) 2012 Team Force LLC. All rights reserved.
6 | //
7 |
8 | #import "CMDataStorage.h"
9 |
10 | #define kSubfolder @"CMStorage"
11 |
12 | @interface CMDataStorage()
13 |
14 | @property (retain) NSURL *cachePath;
15 |
16 | + (NSString *)internalKey:(NSString *)key;
17 | + (BOOL)createDirectoryForURL:(NSURL *)dirPath;
18 |
19 | static NSFileManager * get_file_manager();
20 | static dispatch_queue_t get_disk_io_queue();
21 |
22 | @end
23 |
24 |
25 | @implementation CMDataStorage
26 |
27 |
28 | #pragma mark - Static functions
29 |
30 |
31 | static NSFileManager * get_file_manager() {
32 | static NSFileManager *sharedFileManager;
33 | static dispatch_once_t onceToken;
34 | dispatch_once(&onceToken, ^{
35 | sharedFileManager = [NSFileManager new];
36 | });
37 | return sharedFileManager;
38 | }
39 |
40 | static dispatch_queue_t get_disk_io_queue() {
41 | static dispatch_queue_t _diskIOQueue;
42 | static dispatch_once_t onceToken;
43 | dispatch_once(&onceToken, ^{
44 | _diskIOQueue = dispatch_queue_create("data-disk-cache.io", DISPATCH_QUEUE_CONCURRENT);
45 | });
46 | return _diskIOQueue;
47 | }
48 |
49 |
50 | #pragma mark - Public
51 |
52 |
53 | + (instancetype)sharedCacheStorage {
54 | static dispatch_once_t onceToken;
55 | static CMDataStorage *sharedInstance;
56 | dispatch_once(&onceToken, ^{
57 | sharedInstance = [CMDataStorage new];
58 |
59 | NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
60 | NSString *path = [[paths objectAtIndex:0] stringByAppendingPathComponent:kSubfolder];
61 | sharedInstance.cachePath = [NSURL fileURLWithPath:path isDirectory:YES];
62 |
63 | if (![CMDataStorage createDirectoryForURL:sharedInstance.cachePath]) {
64 | sharedInstance = nil;
65 | }
66 | });
67 | return sharedInstance;
68 | }
69 |
70 | + (instancetype)sharedDocumentsStorage {
71 | static dispatch_once_t onceToken;
72 | static CMDataStorage *sharedInstance;
73 | dispatch_once(&onceToken, ^{
74 | sharedInstance = [CMDataStorage new];
75 |
76 | NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
77 | NSString *path = [[paths objectAtIndex:0] stringByAppendingPathComponent:kSubfolder];
78 | sharedInstance.cachePath = [NSURL fileURLWithPath:path isDirectory:YES];
79 |
80 | if (![CMDataStorage createDirectoryForURL:sharedInstance.cachePath]) {
81 | sharedInstance = nil;
82 | }
83 | });
84 | return sharedInstance;
85 | }
86 |
87 | + (instancetype)sharedTemporaryStorage {
88 | static dispatch_once_t onceToken;
89 | static CMDataStorage *sharedInstance;
90 | dispatch_once(&onceToken, ^{
91 | sharedInstance = [CMDataStorage new];
92 |
93 | sharedInstance.cachePath = [NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES];
94 |
95 | if (![CMDataStorage createDirectoryForURL:sharedInstance.cachePath]) {
96 | sharedInstance = nil;
97 | }
98 | });
99 | return sharedInstance;
100 | }
101 |
102 | - (void)writeData:(NSData *)data key:(NSString *)key block:(void (^)(BOOL succeeds))block {
103 | if (key && [key isKindOfClass:[NSString class]] && [key length] > 0 && data && [data isKindOfClass:[NSData class]]) {
104 | dispatch_async(get_disk_io_queue(), ^{
105 | BOOL succeeds = [data writeToURL:[self fileURLWithKey:key] atomically:YES];
106 |
107 | if (!succeeds) {
108 | NSLog(@"Can't save data to path '%@'", [[self fileURLWithKey:key] path]);
109 | }
110 |
111 | if (block) {
112 | block(succeeds);
113 | }
114 | });
115 | } else if (block) {
116 | block(NO);
117 | }
118 | }
119 |
120 | - (void)dataForKey:(NSString *)key block:(void (^)(NSData *data))block {
121 | if (block && key && [key isKindOfClass:[NSString class]] && [key length] > 0) {
122 | if ([self isStored:key]) {
123 | dispatch_async(get_disk_io_queue(), ^{
124 | NSData *data = [NSData dataWithContentsOfURL:[self fileURLWithKey:key]];
125 | block(data);
126 | });
127 | } else {
128 | block(nil);
129 | }
130 | }
131 | }
132 |
133 | - (void)removeDataForKey:(NSString *)key block:(void (^)(BOOL succeeds))block {
134 | if (key && [key isKindOfClass:[NSString class]] && [key length] > 0) {
135 | if ([self isStored:key]) {
136 | dispatch_async(get_disk_io_queue(), ^{
137 | BOOL succeeds = [get_file_manager() removeItemAtURL:[self fileURLWithKey:key] error:nil];
138 |
139 | if (!succeeds) {
140 | NSLog(@"Can't remove data to path '%@'", [[self fileURLWithKey:key] path]);
141 | }
142 |
143 | if (block) {
144 | block(succeeds);
145 | }
146 | });
147 | } else if (block) {
148 | block(YES);
149 | }
150 | }
151 | }
152 |
153 | - (BOOL)writeData:(NSData *)data key:(NSString *)key {
154 | if (key && [key isKindOfClass:[NSString class]] && [key length] > 0) {
155 | BOOL succeeds = [data writeToURL:[self fileURLWithKey:key] atomically:YES];
156 |
157 | if (!succeeds) {
158 | NSLog(@"Can't save data to path '%@'", [[self fileURLWithKey:key] path]);
159 | }
160 |
161 | return succeeds;
162 | } else {
163 | return NO;
164 | }
165 | }
166 |
167 | - (NSData *)dataForKey:(NSString *)key {
168 | if (key && [key isKindOfClass:[NSString class]] && [key length] > 0) {
169 | if ([self isStored:key]) {
170 | NSData *data = [NSData dataWithContentsOfURL:[self fileURLWithKey:key]];
171 | return data;
172 | } else {
173 | return nil;
174 | }
175 | } else {
176 | return nil;
177 | }
178 | }
179 |
180 | - (BOOL)isStored:(NSString *)key {
181 | if (key && [key isKindOfClass:[NSString class]] && [key length] > 0) {
182 | return [[self fileURLWithKey:key] checkResourceIsReachableAndReturnError:nil];
183 | }
184 |
185 | return NO;
186 | }
187 |
188 | - (NSURL *)fileURLWithKey:(NSString *)key {
189 | if (key && [key isKindOfClass:[NSString class]] && [key length] > 0) {
190 | #ifdef MD5_FOR_KEY
191 | NSString *internalKey = [CMDataStorage internalKey:key];
192 | return [self.cachePath URLByAppendingPathComponent:internalKey isDirectory:NO];
193 | #else
194 | return [self.cachePath URLByAppendingPathComponent:key isDirectory:NO];
195 | #endif
196 | } else {
197 | return nil;
198 | }
199 | }
200 |
201 | - (NSString *)filePathWithKey:(NSString *)key {
202 | return [[self fileURLWithKey:key] path];
203 | }
204 |
205 |
206 | #pragma mark - Private
207 |
208 |
209 | + (NSString *)internalKey:(NSString *)key {
210 | const char *ptr = [key UTF8String];
211 | unsigned char md5Buffer[CC_MD5_DIGEST_LENGTH];
212 | CC_MD5(ptr, strlen(ptr), md5Buffer);
213 | NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
214 |
215 | for (int i = 0; i < CC_MD5_DIGEST_LENGTH; i++) {
216 | [output appendFormat:@"%02x",md5Buffer[i]];
217 | }
218 |
219 | return output;
220 | }
221 |
222 | + (BOOL)createDirectoryForURL:(NSURL *)dirPath {
223 | NSError *error = nil;
224 | [get_file_manager() createDirectoryAtURL:dirPath withIntermediateDirectories:YES attributes:nil error:&error];
225 |
226 | if (error) {
227 | NSLog(@"Fail to create storage directory '%@'", [error localizedDescription]);
228 | }
229 |
230 | return !error;
231 | }
232 |
233 | @end
234 |
--------------------------------------------------------------------------------
/Demo/Pods/CMDataStorage/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2012, Constantine Mureev. All rights reserved.
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
--------------------------------------------------------------------------------
/Demo/Pods/CMDataStorage/README.md:
--------------------------------------------------------------------------------
1 | # CMDataStorage
2 |
3 | [](http://cocoadocs.org/docsets/CMDataStorage)
4 | [](http://cocoadocs.org/docsets/CMDataStorage)
5 |
6 | Simple and powerful lib for read/write NSData from/to iOS Documents / Cache / Temp folder.
7 |
8 | ## Features
9 |
10 | - Extremely simple implementation and powerful API
11 | - Separated GCD queues
12 | - Callbacks based on blocks
13 | - Safe file naming using MD5
14 | - Using modern NSURL iOS API for file paths
15 | - 100% bugs free. (Used in many projects)
16 |
17 | ## Example Usage
18 |
19 | ### Async save NSData in iOS Documents folder
20 |
21 | ```objective-c
22 | NSString *uniqueKey = @"unique name";
23 | [CMDataStorage.sharedDocumentsStorage storeData:data key:uniqueKey block:^(BOOL succeeds) {
24 | //
25 | }];
26 | ```
27 |
28 | ### Async save NSData in iOS Cache folder
29 |
30 | ```objective-c
31 | NSString *uniqueKey = @"unique name";
32 | [CMDataStorage.sharedCacheStorage storeData:data key:uniqueKey block:^(BOOL succeeds) {
33 | //
34 | }];
35 | ```
36 |
37 | ### Async read NSData from iOS Cache folder
38 |
39 | ```objective-c
40 | NSString *uniqueKey = @"unique name";
41 | [CMDataStorage.sharedCacheStorage dataForKey:uniqueKey block:^(NSData *data) {
42 | //
43 | }];
44 | ```
45 |
46 | ### Sync read NSData from iOS Documents folder
47 |
48 | ```objective-c
49 | NSString *uniqueKey = @"unique name";
50 | NSData *data = [CMDataStorage.sharedDocumentsStorage dataForKey:uniqueKey];
51 | ```
52 |
53 | ## License
54 |
55 | CMDataStorage is available under the MIT license. See the LICENSE file for more info.
56 |
--------------------------------------------------------------------------------
/Demo/Pods/Headers/AFNetworking/AFHTTPRequestOperation.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/AFNetworking/AFHTTPRequestOperation.h
--------------------------------------------------------------------------------
/Demo/Pods/Headers/AFNetworking/AFHTTPRequestOperationManager.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/AFNetworking/AFHTTPRequestOperationManager.h
--------------------------------------------------------------------------------
/Demo/Pods/Headers/AFNetworking/AFHTTPSessionManager.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/AFNetworking/AFHTTPSessionManager.h
--------------------------------------------------------------------------------
/Demo/Pods/Headers/AFNetworking/AFNetworkActivityIndicatorManager.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h
--------------------------------------------------------------------------------
/Demo/Pods/Headers/AFNetworking/AFNetworkReachabilityManager.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h
--------------------------------------------------------------------------------
/Demo/Pods/Headers/AFNetworking/AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/AFNetworking/AFNetworking.h
--------------------------------------------------------------------------------
/Demo/Pods/Headers/AFNetworking/AFSecurityPolicy.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/AFNetworking/AFSecurityPolicy.h
--------------------------------------------------------------------------------
/Demo/Pods/Headers/AFNetworking/AFURLConnectionOperation.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/AFNetworking/AFURLConnectionOperation.h
--------------------------------------------------------------------------------
/Demo/Pods/Headers/AFNetworking/AFURLRequestSerialization.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/AFNetworking/AFURLRequestSerialization.h
--------------------------------------------------------------------------------
/Demo/Pods/Headers/AFNetworking/AFURLResponseSerialization.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/AFNetworking/AFURLResponseSerialization.h
--------------------------------------------------------------------------------
/Demo/Pods/Headers/AFNetworking/AFURLSessionManager.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/AFNetworking/AFURLSessionManager.h
--------------------------------------------------------------------------------
/Demo/Pods/Headers/AFNetworking/UIActivityIndicatorView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h
--------------------------------------------------------------------------------
/Demo/Pods/Headers/AFNetworking/UIAlertView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h
--------------------------------------------------------------------------------
/Demo/Pods/Headers/AFNetworking/UIButton+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h
--------------------------------------------------------------------------------
/Demo/Pods/Headers/AFNetworking/UIImageView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h
--------------------------------------------------------------------------------
/Demo/Pods/Headers/AFNetworking/UIKit+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h
--------------------------------------------------------------------------------
/Demo/Pods/Headers/AFNetworking/UIProgressView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h
--------------------------------------------------------------------------------
/Demo/Pods/Headers/AFNetworking/UIWebView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h
--------------------------------------------------------------------------------
/Demo/Pods/Headers/CMDataStorage/CMDataStorage.h:
--------------------------------------------------------------------------------
1 | ../../CMDataStorage/CMDataStorage/CMDataStorage.h
--------------------------------------------------------------------------------
/Demo/Pods/Manifest.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - AFNetworking (2.0.3):
3 | - AFNetworking/NSURLConnection
4 | - AFNetworking/NSURLSession
5 | - AFNetworking/Reachability
6 | - AFNetworking/Security
7 | - AFNetworking/Serialization
8 | - AFNetworking/UIKit
9 | - AFNetworking/NSURLConnection (2.0.3):
10 | - AFNetworking/Reachability
11 | - AFNetworking/Security
12 | - AFNetworking/Serialization
13 | - AFNetworking/NSURLSession (2.0.3):
14 | - AFNetworking/NSURLConnection
15 | - AFNetworking/Reachability (2.0.3)
16 | - AFNetworking/Security (2.0.3)
17 | - AFNetworking/Serialization (2.0.3)
18 | - AFNetworking/UIKit (2.0.3):
19 | - AFNetworking/NSURLConnection
20 | - CMDataStorage (1.1.0)
21 |
22 | DEPENDENCIES:
23 | - AFNetworking
24 | - CMDataStorage
25 |
26 | SPEC CHECKSUMS:
27 | AFNetworking: e499052cbf3d743e9bb727bb37adb9dc2547ba15
28 | CMDataStorage: 1d1f325b29e6b10bd2bc1858bdf838017be5219b
29 |
30 | COCOAPODS: 0.29.0
31 |
--------------------------------------------------------------------------------
/Demo/Pods/Pods-AFNetworking-Private.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Pods-AFNetworking.xcconfig"
2 | GCC_PREPROCESSOR_DEFINITIONS = COCOAPODS=1
3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/BuildHeaders" "${PODS_ROOT}/BuildHeaders/AFNetworking" "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/AFNetworking" "${PODS_ROOT}/Headers/CMDataStorage"
4 | OTHER_LDFLAGS = -ObjC ${PODS_AFNETWORKING_OTHER_LDFLAGS}
5 | PODS_ROOT = ${SRCROOT}
--------------------------------------------------------------------------------
/Demo/Pods/Pods-AFNetworking-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_Pods_AFNetworking : NSObject
3 | @end
4 | @implementation PodsDummy_Pods_AFNetworking
5 | @end
6 |
--------------------------------------------------------------------------------
/Demo/Pods/Pods-AFNetworking-prefix.pch:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #endif
4 |
5 | #import "Pods-environment.h"
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Demo/Pods/Pods-AFNetworking.xcconfig:
--------------------------------------------------------------------------------
1 | PODS_AFNETWORKING_OTHER_LDFLAGS = -framework CoreGraphics -framework MobileCoreServices -framework Security -framework SystemConfiguration
--------------------------------------------------------------------------------
/Demo/Pods/Pods-CMDataStorage-Private.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Pods-CMDataStorage.xcconfig"
2 | GCC_PREPROCESSOR_DEFINITIONS = COCOAPODS=1
3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/BuildHeaders" "${PODS_ROOT}/BuildHeaders/CMDataStorage" "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/AFNetworking" "${PODS_ROOT}/Headers/CMDataStorage"
4 | OTHER_LDFLAGS = -ObjC
5 | PODS_ROOT = ${SRCROOT}
--------------------------------------------------------------------------------
/Demo/Pods/Pods-CMDataStorage-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_Pods_CMDataStorage : NSObject
3 | @end
4 | @implementation PodsDummy_Pods_CMDataStorage
5 | @end
6 |
--------------------------------------------------------------------------------
/Demo/Pods/Pods-CMDataStorage-prefix.pch:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #endif
4 |
5 | #import "Pods-environment.h"
6 |
--------------------------------------------------------------------------------
/Demo/Pods/Pods-CMDataStorage.xcconfig:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mureev/CMHTMLView/15e8a0be3c6dea45a2560c7000aafad6345caba4/Demo/Pods/Pods-CMDataStorage.xcconfig
--------------------------------------------------------------------------------
/Demo/Pods/Pods-acknowledgements.markdown:
--------------------------------------------------------------------------------
1 | # Acknowledgements
2 | This application makes use of the following third party libraries:
3 |
4 | ## AFNetworking
5 |
6 | Copyright (c) 2013 AFNetworking (http://afnetworking.com/)
7 |
8 | Permission is hereby granted, free of charge, to any person obtaining a copy
9 | of this software and associated documentation files (the "Software"), to deal
10 | in the Software without restriction, including without limitation the rights
11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | copies of the Software, and to permit persons to whom the Software is
13 | furnished to do so, subject to the following conditions:
14 |
15 | The above copyright notice and this permission notice shall be included in
16 | all copies or substantial portions of the Software.
17 |
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | THE SOFTWARE.
25 |
26 |
27 | ## CMDataStorage
28 |
29 | Copyright (c) 2012, Constantine Mureev. All rights reserved.
30 |
31 | Permission is hereby granted, free of charge, to any person obtaining a copy
32 | of this software and associated documentation files (the "Software"), to deal
33 | in the Software without restriction, including without limitation the rights
34 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
35 | copies of the Software, and to permit persons to whom the Software is
36 | furnished to do so, subject to the following conditions:
37 |
38 | The above copyright notice and this permission notice shall be included in
39 | all copies or substantial portions of the Software.
40 |
41 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
44 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
45 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
46 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
47 | THE SOFTWARE.
48 | Generated by CocoaPods - http://cocoapods.org
49 |
--------------------------------------------------------------------------------
/Demo/Pods/Pods-acknowledgements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreferenceSpecifiers
6 |
7 |
8 | FooterText
9 | This application makes use of the following third party libraries:
10 | Title
11 | Acknowledgements
12 | Type
13 | PSGroupSpecifier
14 |
15 |
16 | FooterText
17 | Copyright (c) 2013 AFNetworking (http://afnetworking.com/)
18 |
19 | Permission is hereby granted, free of charge, to any person obtaining a copy
20 | of this software and associated documentation files (the "Software"), to deal
21 | in the Software without restriction, including without limitation the rights
22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23 | copies of the Software, and to permit persons to whom the Software is
24 | furnished to do so, subject to the following conditions:
25 |
26 | The above copyright notice and this permission notice shall be included in
27 | all copies or substantial portions of the Software.
28 |
29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
35 | THE SOFTWARE.
36 |
37 | Title
38 | AFNetworking
39 | Type
40 | PSGroupSpecifier
41 |
42 |
43 | FooterText
44 | Copyright (c) 2012, Constantine Mureev. All rights reserved.
45 |
46 | Permission is hereby granted, free of charge, to any person obtaining a copy
47 | of this software and associated documentation files (the "Software"), to deal
48 | in the Software without restriction, including without limitation the rights
49 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
50 | copies of the Software, and to permit persons to whom the Software is
51 | furnished to do so, subject to the following conditions:
52 |
53 | The above copyright notice and this permission notice shall be included in
54 | all copies or substantial portions of the Software.
55 |
56 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
57 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
58 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
59 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
60 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
61 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
62 | THE SOFTWARE.
63 | Title
64 | CMDataStorage
65 | Type
66 | PSGroupSpecifier
67 |
68 |
69 | FooterText
70 | Generated by CocoaPods - http://cocoapods.org
71 | Title
72 |
73 | Type
74 | PSGroupSpecifier
75 |
76 |
77 | StringsTable
78 | Acknowledgements
79 | Title
80 | Acknowledgements
81 |
82 |
83 |
--------------------------------------------------------------------------------
/Demo/Pods/Pods-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_Pods : NSObject
3 | @end
4 | @implementation PodsDummy_Pods
5 | @end
6 |
--------------------------------------------------------------------------------
/Demo/Pods/Pods-environment.h:
--------------------------------------------------------------------------------
1 |
2 | // To check if a library is compiled with CocoaPods you
3 | // can use the `COCOAPODS` macro definition which is
4 | // defined in the xcconfigs so it is available in
5 | // headers also when they are imported in the client
6 | // project.
7 |
8 |
9 | // AFNetworking
10 | #define COCOAPODS_POD_AVAILABLE_AFNetworking
11 | #define COCOAPODS_VERSION_MAJOR_AFNetworking 2
12 | #define COCOAPODS_VERSION_MINOR_AFNetworking 0
13 | #define COCOAPODS_VERSION_PATCH_AFNetworking 3
14 |
15 | // AFNetworking/NSURLConnection
16 | #define COCOAPODS_POD_AVAILABLE_AFNetworking_NSURLConnection
17 | #define COCOAPODS_VERSION_MAJOR_AFNetworking_NSURLConnection 2
18 | #define COCOAPODS_VERSION_MINOR_AFNetworking_NSURLConnection 0
19 | #define COCOAPODS_VERSION_PATCH_AFNetworking_NSURLConnection 3
20 |
21 | // AFNetworking/NSURLSession
22 | #define COCOAPODS_POD_AVAILABLE_AFNetworking_NSURLSession
23 | #define COCOAPODS_VERSION_MAJOR_AFNetworking_NSURLSession 2
24 | #define COCOAPODS_VERSION_MINOR_AFNetworking_NSURLSession 0
25 | #define COCOAPODS_VERSION_PATCH_AFNetworking_NSURLSession 3
26 |
27 | // AFNetworking/Reachability
28 | #define COCOAPODS_POD_AVAILABLE_AFNetworking_Reachability
29 | #define COCOAPODS_VERSION_MAJOR_AFNetworking_Reachability 2
30 | #define COCOAPODS_VERSION_MINOR_AFNetworking_Reachability 0
31 | #define COCOAPODS_VERSION_PATCH_AFNetworking_Reachability 3
32 |
33 | // AFNetworking/Security
34 | #define COCOAPODS_POD_AVAILABLE_AFNetworking_Security
35 | #define COCOAPODS_VERSION_MAJOR_AFNetworking_Security 2
36 | #define COCOAPODS_VERSION_MINOR_AFNetworking_Security 0
37 | #define COCOAPODS_VERSION_PATCH_AFNetworking_Security 3
38 |
39 | // AFNetworking/Serialization
40 | #define COCOAPODS_POD_AVAILABLE_AFNetworking_Serialization
41 | #define COCOAPODS_VERSION_MAJOR_AFNetworking_Serialization 2
42 | #define COCOAPODS_VERSION_MINOR_AFNetworking_Serialization 0
43 | #define COCOAPODS_VERSION_PATCH_AFNetworking_Serialization 3
44 |
45 | // AFNetworking/UIKit
46 | #define COCOAPODS_POD_AVAILABLE_AFNetworking_UIKit
47 | #define COCOAPODS_VERSION_MAJOR_AFNetworking_UIKit 2
48 | #define COCOAPODS_VERSION_MINOR_AFNetworking_UIKit 0
49 | #define COCOAPODS_VERSION_PATCH_AFNetworking_UIKit 3
50 |
51 | // CMDataStorage
52 | #define COCOAPODS_POD_AVAILABLE_CMDataStorage
53 | #define COCOAPODS_VERSION_MAJOR_CMDataStorage 1
54 | #define COCOAPODS_VERSION_MINOR_CMDataStorage 1
55 | #define COCOAPODS_VERSION_PATCH_CMDataStorage 0
56 |
57 |
--------------------------------------------------------------------------------
/Demo/Pods/Pods-resources.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 |
4 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt
5 | > "$RESOURCES_TO_COPY"
6 |
7 | install_resource()
8 | {
9 | case $1 in
10 | *.storyboard)
11 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}"
12 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}"
13 | ;;
14 | *.xib)
15 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}"
16 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}"
17 | ;;
18 | *.framework)
19 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
20 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
21 | echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
22 | rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
23 | ;;
24 | *.xcdatamodel)
25 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\""
26 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom"
27 | ;;
28 | *.xcdatamodeld)
29 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\""
30 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd"
31 | ;;
32 | *.xcassets)
33 | ;;
34 | /*)
35 | echo "$1"
36 | echo "$1" >> "$RESOURCES_TO_COPY"
37 | ;;
38 | *)
39 | echo "${PODS_ROOT}/$1"
40 | echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY"
41 | ;;
42 | esac
43 | }
44 |
45 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
46 | if [[ "${ACTION}" == "install" ]]; then
47 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
48 | fi
49 | rm -f "$RESOURCES_TO_COPY"
50 |
51 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ `xcrun --find actool` ] && [ `find . -name '*.xcassets' | wc -l` -ne 0 ]
52 | then
53 | case "${TARGETED_DEVICE_FAMILY}" in
54 | 1,2)
55 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone"
56 | ;;
57 | 1)
58 | TARGET_DEVICE_ARGS="--target-device iphone"
59 | ;;
60 | 2)
61 | TARGET_DEVICE_ARGS="--target-device ipad"
62 | ;;
63 | *)
64 | TARGET_DEVICE_ARGS="--target-device mac"
65 | ;;
66 | esac
67 | find "${PWD}" -name "*.xcassets" -print0 | xargs -0 actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
68 | fi
69 |
--------------------------------------------------------------------------------
/Demo/Pods/Pods.xcconfig:
--------------------------------------------------------------------------------
1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
2 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/AFNetworking" "${PODS_ROOT}/Headers/CMDataStorage"
3 | OTHER_CFLAGS = $(inherited) "-isystem${PODS_ROOT}/Headers" "-isystem${PODS_ROOT}/Headers/AFNetworking" "-isystem${PODS_ROOT}/Headers/CMDataStorage"
4 | OTHER_LDFLAGS = -ObjC -framework CoreGraphics -framework MobileCoreServices -framework Security -framework SystemConfiguration
5 | PODS_ROOT = ${SRCROOT}/Pods
--------------------------------------------------------------------------------
/Demo/Screenshots/OfflineImages.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mureev/CMHTMLView/15e8a0be3c6dea45a2560c7000aafad6345caba4/Demo/Screenshots/OfflineImages.png
--------------------------------------------------------------------------------
/Demo/Screenshots/Text.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mureev/CMHTMLView/15e8a0be3c6dea45a2560c7000aafad6345caba4/Demo/Screenshots/Text.png
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2012, Constantine Mureev. All rights reserved.
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
--------------------------------------------------------------------------------
/Readme.md:
--------------------------------------------------------------------------------
1 | # CMHTMLView
2 |
3 | [](http://travis-ci.org/mureev/CMHTMLView)
4 | [](http://cocoapods.org/?q=name%3Acmhtmlview%2A)
5 | [](http://cocoapods.org/?q=name%3Acmhtmlview%2A)
6 | 
7 |
8 | ##Deep refactoring completed. Expected API freeze - March 2014. You can use previous version with old API - 0.0.1.
9 |
10 | 
11 | 
12 |
13 | # Features
14 |
15 | * 100% native look and feel
16 | * Offline images support (Any format including animated gif)
17 | * Video support (object YouTube, iframe YouTube, iframe Vimeo)
18 | * All images support Retina display
19 | * Extra Low memory usage
20 | * Stable (never crashed)
21 |
22 | # License
23 |
24 | CMHTMLView is available under the MIT license. See the LICENSE file for more info.
25 |
--------------------------------------------------------------------------------