진동으로 피드백 주기
예전에 스파르타에서 들었던 강의 중에 진동 피드백 줬던 생각과
자주 사용하는 카카오 앱에서 송금할때 진동 피드백을 줬던게 생각이 나서
깃허브에 이름이 존재하지 않을 때 alert 창을 띄우면서 진동으로 피드백 주기를 구현해보았다. (간단하게)
절대 collectionView 구현하기 어려워서 찾아본게 아니다.
async await 실패하고 에러처리도 실패한 코드라 바꿀점이 많은 코드지만
지나가면서 깨달은 점은 메인큐에 넣지 않아도 된다는 점?
let hapticNotification = UINotificationFeedbackGenerator()
@objc func didPressDoneButton(_ sender: UIButton) {
guard let name = self.nameTextField.text else { return }
userDataManager.fetchUser(userId: name) { result in
switch result {
case .success:
DispatchQueue.main.sync {
self.dismiss(animated: true)
}
case .failed:
self.hapticNotification.notificationOccurred(.error) // 틀렸다고 진동
DispatchQueue.main.sync {
self.showAlert()
}
}
}
}
기본적으로 error, success, warning 세가지 진동을 줄 수 있다. (커스텀을 할 수도 있다.)
UITest
엊그제 유닛테스트를 경험해보다가 UITest는 뭐지 ? 하고 호기심에 (삼천포에....) 한번 테스트 해보았다.
정말 간단하게 텍스트필드에 잘못된 이름을 입력했을 때 alert 창이 뜨는지 확인
func test_providedWrongUserName_showAlert() throws {
let app = XCUIApplication()
app.launch()
nameTextField = app.textFields["nameTextField"]
doneButton = app.buttons["doneButton"]
nameTextField.typeText("NEULieeNEULieeNEULieeNEULiee")
doneButton.tap()
XCTAssertTrue(app.alerts["nameAlert"].waitForExistence(timeout: 1), "이름 잘못입력하면 떠야되는데 안떴음")
}
찍어오진 않았지만 자동으로 시뮬레이터가 켜지고 내가 입력한대로 입력하고 테스트해서 결과를 내준다.
너무 신기했다.. ㅎㅎ
이렇게 보니 정말 한거 없다 ㅎ..ㅎ 금토 빡세게 달려서 메인화면은 다 완성해야지..
참조
[iOS] UI Test 간단하게 사용해보기
안녕하세요 Foma👟 입니다! 저번 포스팅엔 Unit Test에 대해서 다뤘는데요 오늘은 UI를 테스트 할 수 있는 UI Test에 대해서 정리를 해보려고 합니다 바로 시작할게요~ UITest Bundle 만들기 Project - General
fomaios.tistory.com
https://www.mongodb.com/docs/realm/sdk/swift/test-and-debug/
Test and Debug - Swift SDK — MongoDB Realm
Docs Home → MongoDB RealmThe easiest way to use and test Realm Database-backed applications is to use the default realm. To avoid overriding application data or leaking state between tests, set the default realm to a new file for each test.class TestCase
www.mongodb.com
'iOS > PROJECT' 카테고리의 다른 글
[두깃] 저장소 추가화면 (CollectionView list + Diffable DataSource) (0) | 2022.04.17 |
---|---|
[두깃] 에러처리 (Result) (0) | 2022.04.14 |
[두깃] 오류 고치는 날 (constraint, Realm migration) (0) | 2022.04.11 |
[두깃] 스토리보드 삭제, 메인화면UI (0) | 2022.04.10 |
[두깃] 깃허브 유저 정보 확인하기 (2022.04.08) (0) | 2022.04.09 |