I'm trying to create a simple controller in swift that allows me to collect photos from the library taken between two precise dates, e.g February the 15th 2015, an February the 18th 2015. During my searches I read about the Photo Framework of iOS, and I'd like to know if there's a simple way to query the photo library with such a framework based on the dates mentioned above. I'd like also to get images metadata like geo location for example. It'd be great if I could do that with the same framework Thanks for your answers
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- SwiftUI: UIImage (QRCode) does not load after call
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Using if let syntax in switch statement
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Enum with associated value conforming to CaseItera
- Swift - hide pickerView after value selected
- Is there a Github markdown language identifier for
First of all I want to say thanks to 'Lyndsey Scott' for such a wonderful code she did. It's really helpful. May be returning errors to few compiler as those are latest one and the code need to be updated a little. So Here I am giving the latest updated code to make Lyndsey's code error free for latest compiler for Swift 4.0 or above.
}
Then use the NSDates to create a predicate for the PHFetchResult's PHFetchOptions.
Happy coding..
To collect the photos between two dates, first you need to create
NSDate
s representing the start and end of the date range. Here's aNSDate
extension (from https://stackoverflow.com/a/24090354/2274694) that can create the dates from their string representations:Then use the
NSDate
s to create a predicate for thePHFetchResult
'sPHFetchOptions
.Updated for Swift 3: