git init
git remote add origin https://github.com/sam98528/Swift_Assignment.git
git config core.sparsecheckout true
echo 'GithubProfile/*' >> .git/info/sparse-checkout
git pull origin main
var userModel = UserModel(user: "sam98528") // Profile를 로드할 user
var repoModel = RepoModel(user: "Apple") // Repository를 로드할 Organization
Github API - Get a User
Github API - List organization repositories
func getUserAlamofire(){
let headers: HTTPHeaders = [
"Authorization": token
]
AF.request(urlString,headers: headers).response { response in
switch response.result {
case .success(let data):
do{
let user = try JSONDecoder().decode(User.self, from: data!)
DispatchQueue.main.async{
self.delegate?.userRetrieved(user: user)
}
}catch {
print("Error Parsing Json")
}
case .failure(let error):
print(error)
}
}
}
func userRetrieved(user: User) {
...
let processor = RoundCornerImageProcessor(cornerRadius: profileImageView.layer.bounds.width)
if let profileImageStr = user.avatar_url{
profileImageView.kf.indicatorType = .activity
profileImageView.kf.setImage(with: URL(string: profileImageStr), options: [.processor(processor)])
}
self.currentUser = user
}
struct User: Codable {
var login: String? // 사용자 아이디
var name: String? // 사용자 이름
var location: String? // 사용자 지역
var followers : Int? // 팔로워 수
var following : Int? // 팔로잉 수
var html_url : String? // 사용자 페이지 URL
var avatar_url : String? // 프로필 이미지 URL
}
struct Repo : Codable {
var name: String? // Repository 이름
var language: String? // Repository 사용 언어
var html_url: String? // Repository URL
}
Pull to Refresh
tableView.refreshControl = UIRefreshControl()
tableView.refreshControl?.addTarget(self, action: #selector(handleRefreshControl), for: .valueChanged)
@objc func handleRefreshControl(){
DispatchQueue.main.asyncAfter(deadline: .now() + 0.7){
self.repoTableView.reloadData()
self.repoTableView.refreshControl?.endRefreshing()
}
}
Paging 처리
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if indexPath.row + 1 == Repo.data.count {
self.repoModel.getRepoAlamofire()
}
}
헉 벌써 챌린지반 과제도 완료하셨군요!!
크..역시 엄청 잘하십니다👍👍