Skip to content

Commit 91cbdbd

Browse files
committed
Add macOS demo and run successfully
1 parent fa9847d commit 91cbdbd

21 files changed

+1476
-4
lines changed

Example/Podfile

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use_frameworks!
22
inhibit_all_warnings!
33

44
target 'SDWebImagePhotosPlugin_Example' do
5+
platform :ios, '8.0'
56
pod 'SDWebImagePhotosPlugin', :path => '../'
67
pod 'SDWebImage/Core', :git => 'https://github.com/rs/SDWebImage.git', :branch => '5.x'
78

@@ -11,3 +12,9 @@ target 'SDWebImagePhotosPlugin_Example' do
1112

1213
end
1314
end
15+
16+
target 'SDWebImagePhotosPlugin_Example macOS' do
17+
platform :osx, '10.13'
18+
pod 'SDWebImagePhotosPlugin', :path => '../'
19+
pod 'SDWebImage/Core', :git => 'https://github.com/rs/SDWebImage.git', :branch => '5.x'
20+
end

Example/Podfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ SPEC CHECKSUMS:
2323
SDWebImage: 55c787b164fabe07f2a4d5307f6e1be7960fb9be
2424
SDWebImagePhotosPlugin: e792a1a12a8eb2af877a90dc1afe1f4245ae2e71
2525

26-
PODFILE CHECKSUM: d6e3b38d111de48b8dba146e3e0c639bdee0aa3a
26+
PODFILE CHECKSUM: ba79f02637d8a9a6f597a92239ee648789cea74c
2727

2828
COCOAPODS: 1.4.0

Example/SDWebImagePhotosPlugin.xcodeproj/project.pbxproj

+241-2
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// AppDelegate.h
3+
// SDWebImagePhotosPlugin_Example macOS
4+
//
5+
// Created by lizhuoli on 2018/7/19.
6+
// Copyright © 2018年 DreamPiggy. All rights reserved.
7+
//
8+
9+
#import <Cocoa/Cocoa.h>
10+
11+
@interface AppDelegate : NSObject <NSApplicationDelegate>
12+
13+
14+
@end
15+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// AppDelegate.m
3+
// SDWebImagePhotosPlugin_Example macOS
4+
//
5+
// Created by lizhuoli on 2018/7/19.
6+
// Copyright © 2018年 DreamPiggy. All rights reserved.
7+
//
8+
9+
#import "AppDelegate.h"
10+
11+
@interface AppDelegate ()
12+
13+
@end
14+
15+
@implementation AppDelegate
16+
17+
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
18+
// Insert code here to initialize your application
19+
}
20+
21+
22+
- (void)applicationWillTerminate:(NSNotification *)aNotification {
23+
// Insert code here to tear down your application
24+
}
25+
26+
27+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "mac",
5+
"size" : "16x16",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "mac",
10+
"size" : "16x16",
11+
"scale" : "2x"
12+
},
13+
{
14+
"idiom" : "mac",
15+
"size" : "32x32",
16+
"scale" : "1x"
17+
},
18+
{
19+
"idiom" : "mac",
20+
"size" : "32x32",
21+
"scale" : "2x"
22+
},
23+
{
24+
"idiom" : "mac",
25+
"size" : "128x128",
26+
"scale" : "1x"
27+
},
28+
{
29+
"idiom" : "mac",
30+
"size" : "128x128",
31+
"scale" : "2x"
32+
},
33+
{
34+
"idiom" : "mac",
35+
"size" : "256x256",
36+
"scale" : "1x"
37+
},
38+
{
39+
"idiom" : "mac",
40+
"size" : "256x256",
41+
"scale" : "2x"
42+
},
43+
{
44+
"idiom" : "mac",
45+
"size" : "512x512",
46+
"scale" : "1x"
47+
},
48+
{
49+
"idiom" : "mac",
50+
"size" : "512x512",
51+
"scale" : "2x"
52+
}
53+
],
54+
"info" : {
55+
"version" : 1,
56+
"author" : "xcode"
57+
}
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}

Example/SDWebImagePhotosPlugin_Example macOS/Base.lproj/Main.storyboard

+717
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>$(DEVELOPMENT_LANGUAGE)</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIconFile</key>
10+
<string></string>
11+
<key>CFBundleIdentifier</key>
12+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleName</key>
16+
<string>$(PRODUCT_NAME)</string>
17+
<key>CFBundlePackageType</key>
18+
<string>APPL</string>
19+
<key>CFBundleShortVersionString</key>
20+
<string>1.0</string>
21+
<key>CFBundleVersion</key>
22+
<string>1</string>
23+
<key>LSMinimumSystemVersion</key>
24+
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
25+
<key>NSHumanReadableCopyright</key>
26+
<string>Copyright © 2018年 DreamPiggy. All rights reserved.</string>
27+
<key>NSMainStoryboardFile</key>
28+
<string>Main</string>
29+
<key>NSPrincipalClass</key>
30+
<string>NSApplication</string>
31+
</dict>
32+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
//
2+
// PHCollection.h
3+
// Photos
4+
//
5+
// Copyright (c) 2013 Apple Inc. All rights reserved.
6+
//
7+
8+
#import <Photos/PHObject.h>
9+
#import <Photos/PHFetchResult.h>
10+
#import <Photos/PhotosTypes.h>
11+
12+
@class PHAsset, PHCollectionList, PHFetchResult, PHFetchOptions;
13+
@class CLLocation;
14+
15+
NS_ASSUME_NONNULL_BEGIN
16+
17+
@interface PHCollection (Private)
18+
19+
@property (nonatomic, assign, readonly) BOOL canContainAssets;
20+
@property (nonatomic, assign, readonly) BOOL canContainCollections;
21+
22+
#pragma mark - Capabilities
23+
24+
- (BOOL)canPerformEditOperation:(PHCollectionEditOperation)anOperation;
25+
26+
27+
#pragma mark - Fetching collections
28+
29+
+ (PHFetchResult<PHCollection *> *)fetchCollectionsInCollectionList:(PHCollectionList *)collectionList options:(nullable PHFetchOptions *)options;
30+
+ (PHFetchResult<PHCollection *> *)fetchTopLevelUserCollectionsWithOptions:(nullable PHFetchOptions *)options;
31+
32+
@end
33+
34+
35+
@interface PHAssetCollection (Private)
36+
37+
@property (nonatomic, assign, readonly) PHAssetCollectionType assetCollectionType;
38+
@property (nonatomic, assign, readonly) PHAssetCollectionSubtype assetCollectionSubtype;
39+
40+
// These counts are just estimates; the actual count of objects returned from a fetch should be used if you care about accuracy. Returns NSNotFound if a count cannot be quickly returned.
41+
@property (nonatomic, assign, readonly) NSUInteger estimatedAssetCount;
42+
43+
@property (nonatomic, strong, readonly, nullable) NSDate *startDate;
44+
@property (nonatomic, strong, readonly, nullable) NSDate *endDate;
45+
46+
@property (nonatomic, strong, readonly, nullable) CLLocation *approximateLocation;
47+
@property (nonatomic, strong, readonly) NSArray<NSString *> *localizedLocationNames;
48+
49+
50+
#pragma mark - Fetching asset collections
51+
52+
// Fetch asset collections of a single type matching the provided local identifiers (type is inferred from the local identifiers)
53+
+ (PHFetchResult<PHAssetCollection *> *)fetchAssetCollectionsWithLocalIdentifiers:(NSArray<NSString *> *)identifiers options:(nullable PHFetchOptions *)options;
54+
55+
// Fetch asset collections of a single type and subtype provided (use PHAssetCollectionSubtypeAny to match all subtypes)
56+
+ (PHFetchResult<PHAssetCollection *> *)fetchAssetCollectionsWithType:(PHAssetCollectionType)type subtype:(PHAssetCollectionSubtype)subtype options:(nullable PHFetchOptions *)options;
57+
58+
// Smart Albums are not supported, only Albums and Moments
59+
+ (PHFetchResult<PHAssetCollection *> *)fetchAssetCollectionsContainingAsset:(PHAsset *)asset withType:(PHAssetCollectionType)type options:(nullable PHFetchOptions *)options;
60+
61+
// assetGroupURLs are URLs retrieved from ALAssetGroup's ALAssetsGroupPropertyURL
62+
+ (PHFetchResult<PHAssetCollection *> *)fetchAssetCollectionsWithALAssetGroupURLs:(NSArray<NSURL *> *)assetGroupURLs options:(nullable PHFetchOptions *)options;
63+
64+
65+
#pragma mark - Fetching moment asset collections
66+
67+
+ (PHFetchResult<PHAssetCollection *> *)fetchMomentsInMomentList:(PHCollectionList *)momentList options:(nullable PHFetchOptions *)options;
68+
+ (PHFetchResult<PHAssetCollection *> *)fetchMomentsWithOptions:(nullable PHFetchOptions *)options;
69+
70+
71+
#pragma mark - Transient asset collections
72+
// These asset collections are only in-memory and are not persisted to disk
73+
74+
+ (PHAssetCollection *)transientAssetCollectionWithAssets:(NSArray<PHAsset *> *)assets title:(nullable NSString *)title;
75+
+ (PHAssetCollection *)transientAssetCollectionWithAssetFetchResult:(PHFetchResult<PHAsset *> *)fetchResult title:(nullable NSString *)title;
76+
77+
78+
@end
79+
80+
81+
@interface PHCollectionList (Private)
82+
83+
@property (nonatomic, assign, readonly) PHCollectionListType collectionListType;
84+
@property (nonatomic, assign, readonly) PHCollectionListSubtype collectionListSubtype;
85+
86+
@property (nonatomic, strong, readonly, nullable) NSDate *startDate;
87+
@property (nonatomic, strong, readonly, nullable) NSDate *endDate;
88+
89+
@property (nonatomic, strong, readonly) NSArray<NSString *> *localizedLocationNames;
90+
91+
92+
#pragma mark - Fetching collection lists
93+
94+
// A PHAssetCollectionTypeMoment will be contained by a PHCollectionListSubtypeMomentListCluster and a PHCollectionListSubtypeMomentListYear
95+
// Non-moment PHAssetCollections will only be contained by a single collection list
96+
+ (PHFetchResult<PHCollectionList *> *)fetchCollectionListsContainingCollection:(PHCollection *)collection options:(nullable PHFetchOptions *)options;
97+
98+
// Fetch collection lists of a single type matching the provided local identifiers (type is inferred from the local identifiers)
99+
+ (PHFetchResult<PHCollectionList *> *)fetchCollectionListsWithLocalIdentifiers:(NSArray<NSString *> *)identifiers options:(nullable PHFetchOptions *)options;
100+
101+
// Fetch asset collections of a single type and subtype provided (use PHCollectionListSubtypeAny to match all subtypes)
102+
+ (PHFetchResult<PHCollectionList *> *)fetchCollectionListsWithType:(PHCollectionListType)collectionListType subtype:(PHCollectionListSubtype)subtype options:(nullable PHFetchOptions *)options;
103+
104+
105+
#pragma mark - Fetching moment collection lists
106+
107+
+ (PHFetchResult<PHCollectionList *> *)fetchMomentListsWithSubtype:(PHCollectionListSubtype)momentListSubtype containingMoment:(PHAssetCollection *)moment options:(nullable PHFetchOptions *)options;
108+
+ (PHFetchResult<PHCollectionList *> *)fetchMomentListsWithSubtype:(PHCollectionListSubtype)momentListSubtype options:(nullable PHFetchOptions *)options;
109+
110+
111+
#pragma mark - Transient collection lists
112+
113+
// These collection lists are only in-memory and are not persisted to disk
114+
+ (PHCollectionList *)transientCollectionListWithCollections:(NSArray<PHCollection *> *)collections title:(nullable NSString *)title;
115+
+ (PHCollectionList *)transientCollectionListWithCollectionsFetchResult:(PHFetchResult<PHCollection *> *)fetchResult title:(nullable NSString *)title;
116+
117+
@end
118+
119+
NS_ASSUME_NONNULL_END
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.app-sandbox</key>
6+
<true/>
7+
<key>com.apple.security.files.user-selected.read-only</key>
8+
<true/>
9+
<key>com.apple.security.assets.pictures.read-write</key>
10+
<true/>
11+
</dict>
12+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// TestCollectionView.h
3+
// SDWebImagePhotosPlugin_Example macOS
4+
//
5+
// Created by lizhuoli on 2018/7/19.
6+
// Copyright © 2018年 DreamPiggy. All rights reserved.
7+
//
8+
9+
#import <Cocoa/Cocoa.h>
10+
11+
@interface TestCollectionView : NSCollectionView
12+
13+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// TestCollectionView.m
3+
// SDWebImagePhotosPlugin_Example macOS
4+
//
5+
// Created by lizhuoli on 2018/7/19.
6+
// Copyright © 2018年 DreamPiggy. All rights reserved.
7+
//
8+
9+
#import "TestCollectionView.h"
10+
11+
@implementation TestCollectionView
12+
13+
- (instancetype)initWithFrame:(NSRect)frameRect {
14+
self = [super initWithFrame:frameRect];
15+
if (self) {
16+
self.wantsLayer = YES;
17+
}
18+
return self;
19+
}
20+
21+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// TestCollectionViewItem.h
3+
// SDWebImagePhotosPlugin_Example macOS
4+
//
5+
// Created by lizhuoli on 2018/7/19.
6+
// Copyright © 2018年 DreamPiggy. All rights reserved.
7+
//
8+
9+
#import <Cocoa/Cocoa.h>
10+
11+
@interface TestCollectionViewItem : NSCollectionViewItem
12+
13+
@property (weak) IBOutlet NSImageView *imageViewDisplay;
14+
15+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// TestCollectionViewItem.m
3+
// SDWebImagePhotosPlugin_Example macOS
4+
//
5+
// Created by lizhuoli on 2018/7/19.
6+
// Copyright © 2018年 DreamPiggy. All rights reserved.
7+
//
8+
9+
#import "TestCollectionViewItem.h"
10+
11+
@implementation TestCollectionViewItem
12+
13+
@end

0 commit comments

Comments
 (0)