Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
Material
Commits
f627b232
Commit
f627b232
authored
Aug 03, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
issue-479: Added PHAssetCollection fetch requests to PhotoLibrary
parent
5c14de2d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
129 additions
and
46 deletions
+129
-46
Sources/iOS/PhotoLibrary.swift
+129
-46
No files found.
Sources/iOS/PhotoLibrary.swift
View file @
f627b232
...
@@ -434,47 +434,6 @@ extension PhotoLibrary {
...
@@ -434,47 +434,6 @@ extension PhotoLibrary {
}
}
}
}
/// PHCollection.
extension
PhotoLibrary
{
/**
Fetches PHCollections in a given PHCollectionList.
- Parameter in collectionList: A PHCollectionList.
- Parameter options: An optional PHFetchOptions object.
- Parameter completion: A completion callback.
*/
public
func
fetchCollections
(
in
collectionList
:
PHCollectionList
,
options
:
PHFetchOptions
?,
completion
:
([
PHCollection
],
PHFetchResult
<
PHCollection
>
)
->
Void
)
{
fetchCollections
(
fetchResult
:
PHCollection
.
fetchCollections
(
in
:
collectionList
,
options
:
options
),
completion
:
completion
)
}
/**
Fetches PHCollections based on a type and subtype.
- Parameter with type: A PHCollectionListType.
- Parameter subtype: A PHCollectionListSubtype.
- Parameter options: An optional PHFetchOptions object.
- Parameter completion: A completion callback.
*/
public
func
fetchTopLevelUserCollections
(
with
options
:
PHFetchOptions
?,
completion
:
([
PHCollection
],
PHFetchResult
<
PHCollection
>
)
->
Void
)
{
fetchCollections
(
fetchResult
:
PHCollection
.
fetchTopLevelUserCollections
(
with
:
nil
),
completion
:
completion
)
}
/**
Fetches the PHCollections for a given PHFetchResult<PHCollection>.
- Parameter fetchResult: A PHFetchResult<PHCollection>.
- Parameter completion: A completion block.
*/
private
func
fetchCollections
(
fetchResult
:
PHFetchResult
<
PHCollection
>
,
completion
:
([
PHCollection
],
PHFetchResult
<
PHCollection
>
)
->
Void
)
{
var
collections
=
[
PHCollection
]()
fetchResult
.
enumerateObjects
({
(
collection
,
_
,
_
)
in
collections
.
append
(
collection
)
})
DispatchQueue
.
main
.
async
{
[
collections
=
collections
,
fetchResult
=
fetchResult
,
completion
=
completion
]
in
completion
(
collections
,
fetchResult
)
}
}
}
/// PHCollectionList.
/// PHCollectionList.
extension
PhotoLibrary
{
extension
PhotoLibrary
{
/**
/**
...
@@ -549,7 +508,7 @@ extension PhotoLibrary {
...
@@ -549,7 +508,7 @@ extension PhotoLibrary {
}
}
/**
/**
Fetches
the
PHCollectionLists for a given PHFetchResult<PHCollectionList>.
Fetches PHCollectionLists for a given PHFetchResult<PHCollectionList>.
- Parameter fetchResult: A PHFetchResult<PHCollectionList>.
- Parameter fetchResult: A PHFetchResult<PHCollectionList>.
- Parameter completion: A completion block.
- Parameter completion: A completion block.
*/
*/
...
@@ -566,6 +525,132 @@ extension PhotoLibrary {
...
@@ -566,6 +525,132 @@ extension PhotoLibrary {
}
}
}
}
/// PHCollection.
extension
PhotoLibrary
{
/**
Fetches PHCollections in a given PHCollectionList.
- Parameter in collectionList: A PHCollectionList.
- Parameter options: An optional PHFetchOptions object.
- Parameter completion: A completion callback.
*/
public
func
fetchCollections
(
in
collectionList
:
PHCollectionList
,
options
:
PHFetchOptions
?,
completion
:
([
PHCollection
],
PHFetchResult
<
PHCollection
>
)
->
Void
)
{
fetchCollections
(
fetchResult
:
PHCollection
.
fetchCollections
(
in
:
collectionList
,
options
:
options
),
completion
:
completion
)
}
/**
Fetches PHCollections based on a type and subtype.
- Parameter with type: A PHCollectionListType.
- Parameter subtype: A PHCollectionListSubtype.
- Parameter options: An optional PHFetchOptions object.
- Parameter completion: A completion callback.
*/
public
func
fetchTopLevelUserCollections
(
with
options
:
PHFetchOptions
?,
completion
:
([
PHCollection
],
PHFetchResult
<
PHCollection
>
)
->
Void
)
{
fetchCollections
(
fetchResult
:
PHCollection
.
fetchTopLevelUserCollections
(
with
:
nil
),
completion
:
completion
)
}
/**
Fetches PHCollections for a given PHFetchResult<PHCollection>.
- Parameter fetchResult: A PHFetchResult<PHCollection>.
- Parameter completion: A completion block.
*/
private
func
fetchCollections
(
fetchResult
:
PHFetchResult
<
PHCollection
>
,
completion
:
([
PHCollection
],
PHFetchResult
<
PHCollection
>
)
->
Void
)
{
var
collections
=
[
PHCollection
]()
fetchResult
.
enumerateObjects
({
(
collection
,
_
,
_
)
in
collections
.
append
(
collection
)
})
DispatchQueue
.
main
.
async
{
[
collections
=
collections
,
fetchResult
=
fetchResult
,
completion
=
completion
]
in
completion
(
collections
,
fetchResult
)
}
}
}
/// PHAssetCollection.
extension
PhotoLibrary
{
/**
Fetch asset collections of a single type matching the provided
local identifiers (type is inferred from the local identifiers).
- Parameter withLocalIdentifiers identifiers: An Array of Strings.
- Parameter options: An optional PHFetchOptions object.
- Parameter completion: A completion block.
*/
public
func
fetchAssetCollections
(
withLocalIdentifiers
identifiers
:
[
String
],
options
:
PHFetchOptions
?,
completion
:
([
PHAssetCollection
],
PHFetchResult
<
PHAssetCollection
>
)
->
Void
)
{
fetchAssetCollections
(
fetchResult
:
PHAssetCollection
.
fetchAssetCollections
(
withLocalIdentifiers
:
identifiers
,
options
:
options
),
completion
:
completion
)
}
/**
Fetch asset collections of a single type and subtype provided
(use PHAssetCollectionSubtypeAny to match all subtypes).
- Parameter with type: A PHAssetCollectionType.
- Parameter subtype: A PHAssetCollectionSubtype.
- Parameter options: An optional PHFetchOptions object.
- Parameter completion: A completion block.
*/
public
func
fetchAssetCollections
(
with
type
:
PHAssetCollectionType
,
subtype
:
PHAssetCollectionSubtype
,
options
:
PHFetchOptions
?,
completion
:
([
PHAssetCollection
],
PHFetchResult
<
PHAssetCollection
>
)
->
Void
)
{
fetchAssetCollections
(
fetchResult
:
PHAssetCollection
.
fetchAssetCollections
(
with
:
type
,
subtype
:
subtype
,
options
:
options
),
completion
:
completion
)
}
/**
Smart Albums are not supported, only Albums and Moments.
- Parameter asset: A PHAsset.
- Parameter with type: A PHAssetCollectionType.
- Parameter options: An optional PHFetchOptions object.
- Parameter completion: A completion block.
*/
public
func
fetchAssetCollectionsContaining
(
_
asset
:
PHAsset
,
with
type
:
PHAssetCollectionType
,
options
:
PHFetchOptions
?,
completion
:
([
PHAssetCollection
],
PHFetchResult
<
PHAssetCollection
>
)
->
Void
)
{
fetchAssetCollections
(
fetchResult
:
PHAssetCollection
.
fetchAssetCollectionsContaining
(
asset
,
with
:
type
,
options
:
options
),
completion
:
completion
)
}
/**
AssetGroupURLs are URLs retrieved from ALAssetGroup's
ALAssetsGroupPropertyURL.
- Parameter withALAssetGroupURLs assetGroupURLs: An Array
of URLs.
- Parameter options: An optional PHFetchOptions object.
- Parameter completion: A completion block.
*/
public
func
fetchAssetCollections
(
withALAssetGroupURLs
assetGroupURLs
:
[
URL
],
options
:
PHFetchOptions
?,
completion
:
([
PHAssetCollection
],
PHFetchResult
<
PHAssetCollection
>
)
->
Void
)
{
fetchAssetCollections
(
fetchResult
:
PHAssetCollection
.
fetchAssetCollections
(
withALAssetGroupURLs
:
assetGroupURLs
,
options
:
options
),
completion
:
completion
)
}
/**
Fetches moments in a given moment list.
- Parameter inMomentList momentList: A PHCollectionList.
- Parameter options: An optional PHFetchOptions object.
- Parameter completion: A completion block.
*/
public
func
fetchMoments
(
inMomentList
momentList
:
PHCollectionList
,
options
:
PHFetchOptions
?,
completion
:
([
PHAssetCollection
],
PHFetchResult
<
PHAssetCollection
>
)
->
Void
)
{
fetchAssetCollections
(
fetchResult
:
PHAssetCollection
.
fetchMoments
(
inMomentList
:
momentList
,
options
:
options
),
completion
:
completion
)
}
/**
Fetches moments.
- Parameter with options: An optional PHFetchOptions object.
- Parameter completion: A completion block.
*/
public
func
fetchMoments
(
with
options
:
PHFetchOptions
?,
completion
:
([
PHAssetCollection
],
PHFetchResult
<
PHAssetCollection
>
)
->
Void
)
{
fetchAssetCollections
(
fetchResult
:
PHAssetCollection
.
fetchMoments
(
with
:
options
),
completion
:
completion
)
}
/**
Fetches PHAssetCollections for a given PHFetchResult<PHAssetCollection>.
- Parameter fetchResult: A PHFetchResult<PHAssetCollection>.
- Parameter completion: A completion block.
*/
private
func
fetchAssetCollections
(
fetchResult
:
PHFetchResult
<
PHAssetCollection
>
,
completion
:
([
PHAssetCollection
],
PHFetchResult
<
PHAssetCollection
>
)
->
Void
)
{
var
collections
=
[
PHAssetCollection
]()
fetchResult
.
enumerateObjects
({
(
collection
,
_
,
_
)
in
collections
.
append
(
collection
)
})
DispatchQueue
.
main
.
async
{
[
collections
=
collections
,
fetchResult
=
fetchResult
,
completion
=
completion
]
in
completion
(
collections
,
fetchResult
)
}
}
}
/// PHAsset.
/// PHAsset.
extension
PhotoLibrary
{
extension
PhotoLibrary
{
/**
/**
...
@@ -615,7 +700,6 @@ extension PhotoLibrary {
...
@@ -615,7 +700,6 @@ extension PhotoLibrary {
fetchAssets
(
fetchResult
:
PHAsset
.
fetchAssets
(
withBurstIdentifier
:
burstIdentifier
,
options
:
options
),
completion
:
completion
)
fetchAssets
(
fetchResult
:
PHAsset
.
fetchAssets
(
withBurstIdentifier
:
burstIdentifier
,
options
:
options
),
completion
:
completion
)
}
}
/**
/**
Fetches PHAssetSourceTypeUserLibrary assets by default (use
Fetches PHAssetSourceTypeUserLibrary assets by default (use
includeAssetSourceTypes option to override).
includeAssetSourceTypes option to override).
...
@@ -626,7 +710,6 @@ extension PhotoLibrary {
...
@@ -626,7 +710,6 @@ extension PhotoLibrary {
fetchAssets
(
fetchResult
:
PHAsset
.
fetchAssets
(
with
:
options
),
completion
:
completion
)
fetchAssets
(
fetchResult
:
PHAsset
.
fetchAssets
(
with
:
options
),
completion
:
completion
)
}
}
/**
/**
Fetch the PHAssets with a given media type.
Fetch the PHAssets with a given media type.
- Parameter in mediaType: A PHAssetMediaType.
- Parameter in mediaType: A PHAssetMediaType.
...
@@ -640,7 +723,7 @@ extension PhotoLibrary {
...
@@ -640,7 +723,7 @@ extension PhotoLibrary {
/**
/**
AssetURLs are URLs retrieved from ALAsset's
AssetURLs are URLs retrieved from ALAsset's
ALAssetPropertyAssetURL.
ALAssetPropertyAssetURL.
- Parameter withALAssetURLs assetURLs: A
PHAssetMediaType
.
- Parameter withALAssetURLs assetURLs: A
n Array of URLs
.
- Parameter options: An optional PHFetchOptions object.
- Parameter options: An optional PHFetchOptions object.
- Parameter completion: A completion block.
- Parameter completion: A completion block.
*/
*/
...
@@ -649,7 +732,7 @@ extension PhotoLibrary {
...
@@ -649,7 +732,7 @@ extension PhotoLibrary {
}
}
/**
/**
Fetches
the
PHAssets for a given PHFetchResult<PHAsset>.
Fetches PHAssets for a given PHFetchResult<PHAsset>.
- Parameter fetchResult: A PHFetchResult<PHAsset>.
- Parameter fetchResult: A PHFetchResult<PHAsset>.
- Parameter completion: A completion block.
- Parameter completion: A completion block.
*/
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment