An iOS app to easily search GitHub users and explore their repositories. Get user details and repository commit insights on the go.
- URLSession
- User Defaults
- Storyboards
- Dynamic Dark Mode
- iOS 14.5+
- Xcode 12.5
You will need Xcode to open and run the app
This app relies on a stable internet connection to obtain a user's GitHub details
Utilizing coding keys and Decodable to obtain and read GitHub's API JSON data properly
struct Repo: Decodable {
let name: String
let owner: Owner
}
struct Owner: Decodable {
let avatarURL: URL?
let login: String
enum CodingKeys: String, CodingKey {
case avatarURL = "avatar_url"
case login
}
}
}
Leveraging the Result type allows for improved handling of success and faliure calls
func fetchRepos(for user: String, completion: @escaping (Result<[Repo], NetworkingError>) -> Void) {
......
}
Error handling included notifying the user of an issue with their request
private let networkManager = NetworkManager()
func fetchRepos(name: String) {
networkManager.fetchRepos(for: name) { [weak self] result in
switch(result) {
case .failure(let error):
DispatchQueue.main.async {
let error = AlertManager.presentAlertControllerWith(alertTitle: "", alertMessage: error.rawValue, dismissActionTitle: "OK")
self?.present(error, animated: true, completion: nil)
}
return
case .success(let repos):
self?.repos = repos
DispatchQueue.main.async {
self?.tableView.reloadData()
}
}
}
}
Ivan Ramirez @IvansTwitter LinkedIn LinkedIn