teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

3

追加。

2017/07/03 05:53

投稿

fuzzball
fuzzball

スコア16733

answer CHANGED
@@ -22,3 +22,11 @@
22
22
  ```
23
23
 
24
24
  `PHFetchOptions`を使ったら、もう少し効率良く出来るかもしれませんが。
25
+
26
+ # 質問編集後の回答
27
+
28
+ ```swift
29
+ self.photosImg = [image!]
30
+ ```
31
+
32
+ 上書きになっているので、追加にして下さい。

2

言い訳。

2017/07/03 05:53

投稿

fuzzball
fuzzball

スコア16733

answer CHANGED
@@ -20,3 +20,5 @@
20
20
  }
21
21
  }
22
22
  ```
23
+
24
+ `PHFetchOptions`を使ったら、もう少し効率良く出来るかもしれませんが。

1

コード追記。

2017/07/03 04:13

投稿

fuzzball
fuzzball

スコア16733

answer CHANGED
@@ -1,4 +1,22 @@
1
1
  至急ということなのでとりあえず。
2
2
  [(iOS8.1)PhotoKitで各種アルバムを取得する](http://qiita.com/takabosoft/items/cb3438f3762f1f59a5ef)
3
3
 
4
- 参考になれば。
4
+ 参考になれば。
5
+
6
+ 【追記】
7
+
8
+ ```swift
9
+ let collections = PHAssetCollection.fetchAssetCollections(with: .album, subtype: .albumRegular, options: nil)
10
+ collections.enumerateObjects { (collection: PHAssetCollection, index: Int, stop) in
11
+ print(index, collection)
12
+ if collection.localizedTitle == "hoge" { //アルバム名
13
+ let assets = PHAsset.fetchAssets(in: collection, options: nil)
14
+ assets.enumerateObjects({ (asset, index, stop) in
15
+ print(index, asset)
16
+ })
17
+ //stop.pointee = true //同じ名前のアルバムが複数存在出来るようなのでstopしない
18
+ } else {
19
+ print(index, "skip")
20
+ }
21
+ }
22
+ ```