App review to demonstrate the following: collection view, custom delegation, persistence using UserDefaults and Documents directory, setting up UI Programmatically, animaation and gestures.
- Collection view
- Custom pogrammatic collection view cell
- User defaults
- Search
- Subclass UITabBarController
- FileManager and documents directory
- Custom delegation
- Programmatic UI
- Segueing view controllers in code
- Animations
- Gestures
- Unit test
In order to run this project you will need an API key to access the New York Times Top Stories API. Once you've registered and acquired an API key, do the following:
- Clone this repo
- Open the Xcode project and navigate to Supporting Files folder delete the Config.swift file and create a new Config.swift file
- Open the newly created Config.swift file and enter the following code below:
struct Config {
static let apiKey = "YOUR API KEY FOR THE NEW YORK TIMES TOP STORIES API GOES HERE"
}
- Run the project
Encapsulating our view controller properties, using dependency injection with designated initializers (Programmatically)
private var dataPersistence: DataPersistence<Article>
private var userPreference: UserPreference
init(_ dataPersistence: DataPersistence<Article>, userPreference: UserPreference) {
self.userPreference = userPreference
self.userPreference.delegate = self
self.dataPersistence = dataPersistence
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
let newsFeedVC = NewsFeedViewController(dataPersistence, userPreference: userPreference)
Encapsulating our view controller properties, using dependency injection with designated initializers (Storyboard)
init?(coder: NSCoder, image: UIImage) {
self.image = image
super.init(coder: coder)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
let image = newsDetailView.newImageView.image ?? UIImage(systemName: "photo")!
let storyboard = UIStoryboard(name: "ZoomImage", bundle: nil)
let zoomImageVC = storyboard.instantiateViewController(identifier: "ZoomImageViewController", creator: { (coder) in
return ZoomImageViewController(coder: coder, image: image)
})
zoomImageVC.modalTransitionStyle = .crossDissolve
present(zoomImageVC, animated: true)