Alamofire 를 활용한 api 통신을 연습하는 튜토리얼
- https://api.androidhive.info/contacts/ api 를 활용한 Alamofire 통신.
- postman 으로 확인한 api. 예제에서는 name, email, gender 만 가져오기로 함.
- SwiftyJSON 이 아닌 swift 자체에서 지원하는 Codable 을 사용해보자. //codable 에 대하 설명 조금.
- tableviewc cell 에 api 에서 가져오 정보를 넣게되면 nil 관련 에럭 나온다. print 해보면 값은 출력되는데 무슨 문제일까?
- 구글링을 해보니 오류의 문제파악이 어긋났다는걸 알았다. nib 파일로 만든 tableview cell 을 제대로 연결해주지 못해서 cell 을 초기화할 수 없어서 옵셔널 관련 에럭 나왔다는 것을 알았다.
//nib 파일이 들어갈 파라미터에 customcell 의 클래스이름을 넣어주었던 것이 잘못.
self.tableView.register(myTableViewCellNib, forCellReuseIdentifier: CustomCell.identifier)
- 출처ㅣ https://stackoverflow.com/questions/35577413/fatal-error-found-nil-while-loading-stock-tableview
- 아래와 같이 constraint 가 아래가 지정되지 않아 tableview 의 automaticDimension 을 사용하면 잘렸다.
-
아래의 constraint를 넣어주니 다보이게 되었다.
-
출처ㅣ https://www.hackingwithswift.com/forums/ios/uitableview-automatic-row-height-programatically/2203