Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Conversation

intmain
Copy link
Collaborator

@intmain intmain commented Sep 26, 2017

reqeust

return json.arrayValue.map{
Model.Issue(json: $0)
}
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

뭔가 좀더 간단히 할 수 있을 것 같은데..

let result = dataResponse.map { $0.arrayValue }.map { Model.Issue(json: $0) }

}

typealias IssueResponsesHandler = (DataResponse<[Model.Issue]>) -> Void
static func repoIssues(owner: String, repo: String) -> (Int, @escaping IssueResponsesHandler) -> Void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typealias는 class 밖에 있는게 더 읽기 편할듯?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API. IssueResponsesHandler 보다 IssueResponsesHandler가 나아보이나요?

if !GlobalState.instance.isLoggedIn {
let loginViewController = LoginViewController.viewController
DispatchQueue.main.asyncAfter(deadline: .now() + 0.0, execute: { [weak self] in
self?.window?.rootViewController?.present(loginViewController, animated: false, completion: nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기야 말로 unowned로 써도 되겠네요?
아니면... 이렇게 회피? ㅋㅋㅋ

UIApplication.shared.delegate?.window?.rootViewController?.present(loginViewController, animated: false, completion: nil)

print(issue)
self.createdIssue = issue
self.performSegue(withIdentifier: "UnwindToIssues", sender: self)
case .failure(_):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거도 case .failure:

static let tokenKey = "token"
static let ownerKey = "owner"
static let repoKey = "repo"
static let reposKey = "repos"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

전 이런 공백 극혐함 ㅋㅋ

var token: String? {
get {
let token = UserDefaults.standard.string(forKey: constants.tokenKey)
return token
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

token 변수가 불필요?

"body": body,
"state": state.display,
"user": ["id": user.id, "login": user.login, "acatar_url": (user.avatarURL?.absoluteString ?? "")]
] as [String : Any]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

윽 이부분 읽기 어렵네요.
탭 좀..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그리고 결국 타입이 [String:Any] 라면 변수에 적어주는게 더 좋겠네요.

var dict: [String : Any] = [
  "id": id,
  "number": number,
  "title": title,
  "comments": comments,
  "body": body,
  "state": state.display,
  "user": [
    "id": user.id, 
    "login": user.login, 
    "acatar_url": (user.avatarURL?.absoluteString ?? "")
  ]
]

enum State: String {
case open = "open"
case closed = "closed"
case none = "none"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String 을 상속받고 case 와 rawValue 가 같으면 rawValue 따로 안 써도 됩니다.

enum State: String {
  case open
  case closed
  case none
}

switch self {
case .open: return "opened"
case .closed: return "closed"
default: return "-"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

case none:


static var cellFromNib: IssueCell {
get {
return Bundle.main.loadNibNamed("IssueCell", owner: nil, options: nil)?.first as! IssueCell
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오류날 일은 없겠지만... 그래도 as!는 위험하니

guard let cell = Bundle.main.loadNibNamed("IssueCell", owner: nil, options: nil)?.first as? IssueCell else { 
  assertionFailure()
  return IssueCell() 
}
return cell

}
}

func update(data issue: Model.Issue) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

func update(issue: Model.Issue) {

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 이거는 프로토콜때매 data

final class IssueCommentCell: UICollectionViewCell, CellProtocol {


@IBOutlet var bodyLabel: UILabel!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

빈줄은 한줄


@IBOutlet var commentTextField: UITextField!
var owner: String = ""
var repo: String = ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

빈줄이 IBOutlet 두개 사이가 아니라 owner 와 commentTextField 사이에 들어가는게 더 보기 좋을 것 같네요

var owner: String = ""
var repo: String = ""
var issue: Model.Issue!
var headerSize: CGSize = CGSize.zero
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

줄임 가능

var headerSize: CGSize = .zero

@IBAction func sendButtonTapped(_ sender: Any) {
let comment = commentTextField.text ?? ""
API.createComment(owner: owner, repo: repo, number: issue.number, comment: comment) { [weak self] (dataResponse: DataResponse<Model.Comment>) in
guard let `self` = self else { return }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거에 대한 의견도 많죠.
self는 안 쓰자는 주의 ㅋ
[weak self] 를 놓쳤을때 찾기가 쉽지 않아서..


default:

assert(false, "Unexpected element kind")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertionFailure("Unexpected element kind")


}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let detailViewController = segue.destination as? IssueDetailViewController,let issue = sender as? Model.Issue {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기서는 segue.identifier 인가로 비교하는게 좋지 않나요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

분기의 목적보다는 까려는 목적? 어케 생각하시나요?


case UICollectionElementKindSectionHeader:
assert(false, "Unexpected element kind")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이렇게 사용하시면 release 빌드에서 오류납니다.
assert외에 다른 문장이 없으면 항상 break를 같이 넣어주세요

estimatedLayout[key] = nil
} else {
estimatedLayout = [:]
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

개인 취향

guard let key = indexPath else { 
  estimatedLayout = [:]
  return
}
estimatedLayout[key] = nil

func estimateLayoutAttributes(_ layoutAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes {
if layoutAttributes.isHidden {
return layoutAttributes
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guard layoutAttributes.isHidden == false else { return layoutAttributes }

if needRefreshDatasource {
datasource = []
needRefreshDatasource = false
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거야 말로 guard를 써야 할때

guard needRefreshDatasource == true else { return }
datasource = []
needRefreshDatasource = false

var page: Int = 1
var canLoadMore: Bool = true
fileprivate var estimatedSizes: [IndexPath: CGSize] = [:]
fileprivate let estimateCell: CellType = CellType.cellFromNib
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

멤버변수 선언이 정신이 없네요.
accessor 별로 분류 하거나 기능별로 분류하거나 뭔가 기준이 있으면 좋을 것 같아요

var api: ((Int, @escaping IssueResponsesHandler) -> Void)?

func loadMore(indexPath: IndexPath) {
guard indexPath.item == datasource.count - 1 && !isLoading && canLoadMore else { return }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guard 뒤에 공백이 2개!

}

func load() {
guard isLoading == false else {return }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return 앞에 공백 필요

func load() {
guard isLoading == false else {return }
isLoading = true
api?(page, {[weak self] (response: DataResponse<[Item]>) -> Void in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api?(page) { [weak self] (response: DataResponse<[Item]>) -> Void in

canLoadMore = false
loadMoreCell?.loadDone()

}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

의미없는 빈줄인것 같네요

가져온 사이즈를 인덱싱.
그 사이즈를 리턴.

*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

불필요한 주석?



@IBAction func unwindFromRepos(_ segue: UIStoryboardSegue) {
if let reposViewController = segue.source as? ReposViewController, let (owner, repo) = reposViewController.selectedRepo {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이것도 guard가 더 깔끔?

GlobalState.instance.token = ""
let loginViewController = LoginViewController.viewController
DispatchQueue.main.asyncAfter(deadline: .now() + 0.0, execute: { [weak self] in
self?.present(loginViewController, animated: true, completion: nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DispatchQueue.main.asyncAfter(deadline: .now() + 0.0) { [weak self] in

return .put
case .repoIssues,
.issueDetail
:
Copy link
Member

@yoonhg84 yoonhg84 Sep 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

콜론을 왜 내리셨나요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API는 한개씩 추가되니까 아래줄에 하나씩만 추가하려고요

let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
UIGraphicsBeginImageContext(rect.size)

if let context = UIGraphicsGetCurrentContext() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이것도 guard가 깔끔

Copy link
Collaborator Author

@intmain intmain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

typealias IssueResponsesHandler = (DataResponse<[Model.Issue]>) -> Void
static func repoIssues(owner: String, repo: String) -> (Int, @escaping IssueResponsesHandler) -> Void {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API. IssueResponsesHandler 보다 IssueResponsesHandler가 나아보이나요?

}
}

func update(data issue: Model.Issue) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 이거는 프로토콜때매 data


}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let detailViewController = segue.destination as? IssueDetailViewController,let issue = sender as? Model.Issue {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

분기의 목적보다는 까려는 목적? 어케 생각하시나요?

return .put
case .repoIssues,
.issueDetail
:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API는 한개씩 추가되니까 아래줄에 하나씩만 추가하려고요

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants