-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change hard-coded preview data to not hard-coded #25
base: develop
Are you sure you want to change the base?
Conversation
43d8d21
to
f242c4d
Compare
이렇게 되면 함수를 파트1 파트2 처럼 나눌 수밖에 없어지니 린트는 포기하겠습니다. |
@minacle 제안드리자면, 어차피 프리뷰 데이터인 만큼 Reflection을 써서 값을 대입하는 방법도 있습니다. |
1a1983b
to
c1376f4
Compare
6c40ef4
to
c96adf3
Compare
c96adf3
to
4986129
Compare
.swiftlint.yml
Outdated
@@ -10,6 +10,10 @@ opt_in_rules: | |||
- empty_collection_literal | |||
- empty_string | |||
|
|||
cyclomatic_complexity: | |||
warning: 20 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: 20 | |
warning: 15 |
context: NSManagedObjectContext? = nil, | ||
save: Bool = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
save parameter를 받는 이유가 있을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
외부에서 context를 제공했을 경우 여러 파일을 한꺼번에 읽어들인 뒤 직접 한 번만 저장할 수도 있습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
context를 받지 않거나, default 값에서 nil 대신 아에 background context를 생성하는 것도 좋을 것 같습니다.
@@ -0,0 +1,262 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plist를 선택한 이유가 있을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
간편하기 때문입니다.
let state = _PreviewDataInjectionState(bundle: bundle) | ||
for (userID, previewUserDetails) in previewManifest.userDetails { | ||
state.userDetail = nil | ||
for previewUserDetail in previewUserDetails { | ||
let userDetail = _injectPreviewUserDetail(previewUserDetail, state: state, context: context) | ||
if state.userIDToUserDetail[userID] == nil { | ||
state.userIDToUserDetail[userID] = userDetail | ||
} | ||
state.userDetail = userDetail | ||
} | ||
} | ||
for (userID, userDetail) in state.userIDToUserDetail { | ||
state.userDetail = userDetail | ||
_injectPreviewUser(id: userID, state: state, context: context) | ||
} | ||
for userID in previewManifest.accounts { | ||
guard let userDetail = state.userIDToUserDetail[userID] else { | ||
continue | ||
} | ||
state.userDetail = userDetail | ||
_injectPreviewAccount(userID: userID, state: state, context: context) | ||
} | ||
for (userID, previewUserDataAssets) in previewManifest.dataAssets { | ||
guard let userDetail = state.userIDToUserDetail[userID] else { | ||
continue | ||
} | ||
state.userDetail = userDetail | ||
for previewUserDataAsset in previewUserDataAssets { | ||
_injectPreviewUserDataAsset(previewUserDataAsset, state: state, context: context) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
state를 사용하여 넣는 형태가 필요에 비해 과한 것 같습니다.
좀 더 단순하게 할 수 있을 것 같습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좀 더 단순하게 하면 복잡도가 30에 달합니다.
This reverts commit d2683c2.
No description provided.