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
2f4ac3e2
Commit
2f4ac3e2
authored
Aug 03, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
issue-479: completed the PHCollectionList fetch requests for PhotoLibrary
parent
b24662a9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
120 additions
and
5 deletions
+120
-5
Sources/iOS/PhotoLibrary.swift
+120
-5
No files found.
Sources/iOS/PhotoLibrary.swift
View file @
2f4ac3e2
...
...
@@ -462,6 +462,30 @@ extension PhotoLibrary {
/// PHCollectionList.
extension
PhotoLibrary
{
/**
A PHAssetCollectionTypeMoment collection type will be contained
by a PHCollectionListSubtypeMomentListCluster and a
PHCollectionListSubtypeMomentListYear. Non-moment PHAssetCollections
will only be contained by a single collection list.
- Parameter _ collection: A PHCollection.
- Parameter options: An optional PHFetchOptions object.
- Parameter completion: A completion callback.
*/
public
func
fetchCollectionListsContaining
(
_
collection
:
PHCollection
,
options
:
PHFetchOptions
?,
completion
:
([
PHCollectionList
],
PHFetchResult
<
PHCollectionList
>
)
->
Void
)
{
var
lists
=
[
PHCollectionList
]()
let
fetchResult
=
PHCollectionList
.
fetchCollectionListsContaining
(
collection
,
options
:
options
)
defer
{
DispatchQueue
.
main
.
async
{
[
lists
=
lists
,
fetchResult
=
fetchResult
,
completion
=
completion
]
in
completion
(
lists
,
fetchResult
)
}
}
fetchResult
.
enumerateObjects
({
(
list
,
_
,
_
)
in
lists
.
append
(
list
)
})
}
/**
Fetch PHCollectionLists based on a type and subtype.
- Parameter with type: A PHCollectionListType.
- Parameter subtype: A PHCollectionListSubtype.
...
...
@@ -478,9 +502,100 @@ extension PhotoLibrary {
}
}
fetchResult
.
enumerateObjects
(
options
:
[
.
concurrent
])
{
(
list
,
_
,
_
)
in
fetchResult
.
enumerateObjects
({
(
list
,
_
,
_
)
in
lists
.
append
(
list
)
})
}
/**
Fetch collection lists of a single type matching the
provided local identifiers (type is inferred from the
local identifiers).
- Parameter withLocalIdentifier identifiers: An Array
of String identifiers.
- Parameter options: An optional PHFetchOptions object.
- Parameter completion: A completion callback.
*/
public
func
fetchCollectionLists
(
withLocalIdentifiers
identifiers
:
[
String
],
options
:
PHFetchOptions
?,
completion
:
([
PHCollectionList
],
PHFetchResult
<
PHCollectionList
>
)
->
Void
)
{
var
lists
=
[
PHCollectionList
]()
let
fetchResult
=
PHCollectionList
.
fetchCollectionLists
(
withLocalIdentifiers
:
identifiers
,
options
:
options
)
defer
{
DispatchQueue
.
main
.
async
{
[
lists
=
lists
,
fetchResult
=
fetchResult
,
completion
=
completion
]
in
completion
(
lists
,
fetchResult
)
}
}
fetchResult
.
enumerateObjects
({
(
list
,
_
,
_
)
in
lists
.
append
(
list
)
})
}
/**
Fetch asset collections of a single type and subtype
provided (use PHCollectionListSubtypeAny to match all
subtypes).
- Parameter with collectionListType: A PHCollectionListType.
- Parameter subtype: A PHCollectionListSubtype.
- Parameter options: An optional PHFetchOptions object.
- Parameter completion: A completion callback.
*/
public
class
func
fetchCollectionLists
(
with
collectionListType
:
PHCollectionListType
,
subtype
:
PHCollectionListSubtype
,
options
:
PHFetchOptions
?,
completion
:
([
PHCollectionList
],
PHFetchResult
<
PHCollectionList
>
)
->
Void
)
{
var
lists
=
[
PHCollectionList
]()
let
fetchResult
=
PHCollectionList
.
fetchCollectionLists
(
with
:
collectionListType
,
subtype
:
subtype
,
options
:
options
)
defer
{
DispatchQueue
.
main
.
async
{
[
lists
=
lists
,
fetchResult
=
fetchResult
,
completion
=
completion
]
in
completion
(
lists
,
fetchResult
)
}
}
fetchResult
.
enumerateObjects
({
(
list
,
_
,
_
)
in
lists
.
append
(
list
)
})
}
/**
Fetch moment lists containing a given moment.
- Parameter with momentListSubtype: A PHCollectionListSubtype.
- Parameter containingMoment moment: A PHAssetCollection.
- Parameter options: An optional PHFetchOptions object.
- Parameter completion: A completion callback.
*/
public
class
func
fetchMomentLists
(
with
momentListSubtype
:
PHCollectionListSubtype
,
containingMoment
moment
:
PHAssetCollection
,
options
:
PHFetchOptions
?,
completion
:
([
PHCollectionList
],
PHFetchResult
<
PHCollectionList
>
)
->
Void
)
{
var
lists
=
[
PHCollectionList
]()
let
fetchResult
=
PHCollectionList
.
fetchMomentLists
(
with
:
momentListSubtype
,
containingMoment
:
moment
,
options
:
options
)
defer
{
DispatchQueue
.
main
.
async
{
[
lists
=
lists
,
fetchResult
=
fetchResult
,
completion
=
completion
]
in
completion
(
lists
,
fetchResult
)
}
}
fetchResult
.
enumerateObjects
({
(
list
,
_
,
_
)
in
lists
.
append
(
list
)
})
}
/**
Fetch moment lists.
- Parameter with momentListSubtype: A PHCollectionListSubtype.
- Parameter options: An optional PHFetchOptions object.
- Parameter completion: A completion callback.
*/
public
func
fetchMomentLists
(
with
momentListSubtype
:
PHCollectionListSubtype
,
options
:
PHFetchOptions
?,
completion
:
([
PHCollectionList
],
PHFetchResult
<
PHCollectionList
>
)
->
Void
)
{
var
lists
=
[
PHCollectionList
]()
let
fetchResult
=
PHCollectionList
.
fetchMomentLists
(
with
:
momentListSubtype
,
options
:
options
)
defer
{
DispatchQueue
.
main
.
async
{
[
lists
=
lists
,
fetchResult
=
fetchResult
,
completion
=
completion
]
in
completion
(
lists
,
fetchResult
)
}
}
fetchResult
.
enumerateObjects
({
(
list
,
_
,
_
)
in
lists
.
append
(
list
)
})
}
}
...
...
@@ -504,9 +619,9 @@ extension PhotoLibrary {
fetchResult
=
PHAsset
.
fetchAssets
(
in
:
assetCollection
,
options
:
options
)
fetchResult
.
enumerateObjects
(
options
:
[])
{
(
asset
,
_
,
_
)
in
fetchResult
.
enumerateObjects
({
(
asset
,
_
,
_
)
in
assets
.
append
(
asset
)
}
}
)
}
/**
...
...
@@ -527,9 +642,9 @@ extension PhotoLibrary {
fetchResult
=
PHAsset
.
fetchAssets
(
with
:
mediaType
,
options
:
options
)
fetchResult
.
enumerateObjects
(
options
:
[])
{
(
asset
,
_
,
_
)
in
fetchResult
.
enumerateObjects
({
(
asset
,
_
,
_
)
in
assets
.
append
(
asset
)
}
}
)
}
}
...
...
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