0

I'm learning about PHAsset - Photos in Swift, when i get all the selected photos y print on console the object that return:

Finish: **[<PHAsset: 0x10205cb20> A7BE6AF3-3402-484C-8C21-CAE3A6CA9AB0/L0/001 mediaType=1/0, sourceType=1, (255x199), creationDate=4501-01-01 6:00:00 a.m. +0000, location=0, hidden=0, favorite=0 , <PHAsset: 0x10207de00> 8450D61E-1DA8-4F11-A9BC-2CC8425D201C/L0/001 mediaType=1/0, sourceType=1, (459x387), creationDate=2016-11-15 2:22:11 p.m. +0000, location=0, hidden=0, favorite=0 , <PHAsset: 0x10207dcb0> 59DA604E-81EF-4A78-AF06-1E2771775D4C/L0/001 mediaType=1/0, sourceType=1, (480x480), creationDate=2016-11-15 6:15:03 a.m. +0000, location=0, hidden=0, favorite=0 ]**

Of 3 photos that i Selected, im not sure how it works at all, i want to save the information in one Array to retrieve that info.

Can you give any advice how can i iterate that object?

Thanks and regards.

NSNoob
  • 5,548
  • 6
  • 41
  • 54
  • That _is_ one array, so it's hard to see what you are asking. Perhaps if you would show _your_ code the nature of the problem would be clearer. – matt Nov 15 '16 at 18:52
  • Sorry, its beacuse that is an PHAsset Collection i want save the identificator on my own array for example " A7BE6AF3-3402-484C-8C21-CAE3A6CA9AB0/L0/001" its the ID of the photo but i can't access. The whole Objet gives me: [ A7BE6AF3-3402-484C-8C21-CAE3A6CA9AB0/L0/001 mediaType=1/0, sourceType=1, (255x199), creationDate=4501-01-01 6:00:00 a.m. +0000, location=0, hidden=0, favorite=0] – Ulysses Marx Nov 15 '16 at 19:21
  • See my previous answer [here](http://stackoverflow.com/questions/39587405/how-to-fetch-images-from-photo-library-within-range-of-two-dates-in-ios/39588274#39588274) On how to fetch and use PHassets. It's in Obj C but shouldn't be difficult to understand for someone who can understand Swift. And of course, ignore the predicate about date range – NSNoob Nov 15 '16 at 19:37

1 Answers1

0

What you get back when you do a fetch is a PHFetchResult. You can cycle through it like this:

for ix in 0..<result.count {
    let asset = result[ix]
    // do something with the asset
}

So you could build an array of unique identifiers in that loop.

matt
  • 515,959
  • 87
  • 875
  • 1,141