{"id":19372022,"url":"https://github.com/dev-junehee/bmi-calculator","last_synced_at":"2026-05-16T10:32:31.655Z","repository":{"id":240887604,"uuid":"803691636","full_name":"dev-junehee/BMI-Calculator","owner":"dev-junehee","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-22T13:47:42.000Z","size":251,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-24T14:49:16.188Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dev-junehee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-21T07:56:13.000Z","updated_at":"2024-05-22T13:47:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"bed9dd95-8c8e-46d1-ac2c-0351866dcc43","html_url":"https://github.com/dev-junehee/BMI-Calculator","commit_stats":null,"previous_names":["dev-junehee/bmi-calculator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dev-junehee/BMI-Calculator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-junehee%2FBMI-Calculator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-junehee%2FBMI-Calculator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-junehee%2FBMI-Calculator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-junehee%2FBMI-Calculator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dev-junehee","download_url":"https://codeload.github.com/dev-junehee/BMI-Calculator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-junehee%2FBMI-Calculator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33098793,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T04:41:52.686Z","status":"ssl_error","status_checked_at":"2026-05-16T04:41:52.009Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T08:21:07.713Z","updated_at":"2026-05-16T10:32:31.640Z","avatar_url":"https://github.com/dev-junehee.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BMI-Calculator\n\n\u003e **BMI 계산법**\u003cbr /\u003e\n\u003e 신체질량지수(BMI) = $체중(kg) / (신장(m))^2$\n\n\u003cbr /\u003e\n\n## Study for\n- Auto Layout\n- TextField, Button, @Outlet, @IBAction\n- UIAlertController, Alert, Actionsheet\n    - style: default, destructive, cancel\n- 함수의 반환 값, @discardableResult\n- Optional Chaining, Optional Binding\n- UserDefaults\n\n\u003cbr /\u003e\n\n## To-do\n### 기능\n- [ ] 키와 몸무게 입력 받기\n    - [x] 숫자 키패드 사용\n    - [x] Int, Float, Double(정수와 실수) 구분\n    - [ ] 몸무게 입력 시 입력값 안보이게 설정\n    - [x] UserDefaults에 데이터 저장\n    - [x] 기존 데이터 기록이 남아있으면 TextField에 기본 노출\n    - [x] 초기화 버튼 클릭 시 UserDefaults 데이터 삭제\n- [x] 키보드 내리기\n    - [x] 백그라운드 tap 했을 때\n    - [ ] ~~키보드 return 눌렀을 때~~ (→ 숫자 키패드로 변경)\n- [x] BMI 계산하기\n    - [x] BMI 계산 함수 생성\n    - [x] 키와 몸무게 매개변수 받기\n    - [x] 신장 단위 변경 (cm(센티미터) → m(미터))\n    - [x] BMI 결과 Alert 연결\n    - [x] BMI 결과 소숫점 반올림\n- [x] 랜덤으로 BMI 계산하기\n    - [x] 임의의 데이터 셋 구성 (→ `Double.random()` 사용)\n    - [x] 랜덤한 값으로 BMI 계산\n- [x] 예외 처리 (옵셔널 체이닝, 옵셔널 바인딩)\n    - [x] 키/몸무게 텍스트 필드에 문자가 입력됐을 때\n    - [x] 키/몸무게 범위가 잘못됐을 때 (일반적이지 않은 경우)\n    - [x] 공백이나 빈칸이 입력됐을 때\n### 디자인\n- [x] AutoLayout을 활용한 화면 배치 (다양한 기종 대응)\n    - [x] iPhone SE\n    - [x] iPhone 13 mini\n    - [x] iPhone 15\n    - [x] iPhone 15 Pro\n    - [x] iphoone 15 Pro Max\n- [ ] TextField\n    - [ ] highlight borderColor 변경\n    - [x] 왼쪽 패딩 (UITextField.leftView, .leftViewMode 사용)\n- [x] Alert\n\n\u003cbr /\u003e\n\n## Refactoring\n#### 24-05-22 (Wed)\n- [x] 반복되는 코드 함수화\n- [x] UserDefaults 사용한 사용자 데이터 영구 저장/삭제\n\n\u003cbr /\u003e\n\n## 화면 구성\n\n| **런치 스크린** | **메인 화면** | **메인 화면\u003cbr /\u003e(UserDefaults)** | **Alert\u003cbr /\u003e(결과 확인 버튼 클릭)** |\n|:--------:|:-------:|:-----:|:-----:|\n| | \u003cimg width=\"400\" alt=\"메인화면\" src=\"https://github.com/dev-junehee/BMI-Calculator/assets/116873887/e6c53e1b-3527-497a-92d7-92f820854a7f\"\u003e | \u003cimg width=\"400\" alt=\"메인화면-디폴트값\" src=\"https://github.com/dev-junehee/BMI-Calculator/assets/116873887/13f68929-5b74-478d-a612-c86baa60ff69\"\u003e | \u003cimg width=\"400\" alt=\"Alert-result\" src=\"https://github.com/dev-junehee/BMI-Calculator/assets/116873887/96bf8290-d9dd-47ad-84f0-b31d3b093f32\"\u003e |\n | **Alert**\u003cbr /\u003e(키가 범위를 벗어났을 때) | **Alert**\u003cbr /\u003e(몸무게가 범위를 벗어났을 때) | **Alert**\u003cbr /\u003e(랜덤 버튼 클릭했을 때) |\n | \u003cimg width=\"400\" alt=\"Alert-height\" src=\"https://github.com/dev-junehee/BMI-Calculator/assets/116873887/c7ca9e1a-b9e7-47d3-9508-561f44c71c65\"\u003e | \u003cimg width=\"400\" alt=\"Alert-weight\" src=\"https://github.com/dev-junehee/BMI-Calculator/assets/116873887/a3b92cec-bdff-4827-80a0-66e80873b495\"\u003e | \u003cimg width=\"400\" alt=\"Alert-random\" src=\"https://github.com/dev-junehee/BMI-Calculator/assets/116873887/a6ffd69b-c542-4480-95ea-48775f900c3f\"\u003e |\n\n\u003cbr /\u003e\n\n## Question\n\u003cdetails\u003e\n\u003csummary\u003eSwift에서 상수 선언 시 상수명 명명법\u003c/summary\u003e\n\u003cdiv markdown=\"1\"\u003e\nJavaScript에서 상수(Constants) 데이터를 만들 때 객체를 활용해 선언하고, 상수명은 대문자 스네이크 케이스(e.g. TEXT_DATA)를 활용했었다. Swift에서는 기본으로 카멜 케이스(camelCase)를 사용하고 카멜 케이스 안에서도 Lower Camel Case 와 Upper Camel Case로 나뉘어지는데, 상수 선언의 경우에는 Lower Camel Case를 사용한다고 한다. 따라서 앱에서 사용할 문자열을 딕셔너리(Dictionary)를 활용해 상수를 선언하고, 상수명은 Lower Camel Case 규칙을 적용해주었다.\n\n\u003c/div\u003e\n\u003c/details\u003e\n\n\u003cbr /\u003e\n\n## Trouble Shooting\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eAppDeleagate에서 Thread 1: signal SIGTERM error\u003c/b\u003e\u003c/summary\u003e\n여러 개의 시뮬레이터를 켜놓고 테스트 하던 중 시뮬레이터를 종료하니 AppDelegate에서 Thread 1 Error 발생\nXcode에서 시뮬레이터를 종료할 때 Cmd + Q를 사용해야 한다고 한다. (iOS 13 이후부터 AppDelegate에서 앱의 생성과 종료 시점 통제)\n\u003c/div\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e숫자 키패드 입력값 입력 후 userData에 할당되지 않는 이슈\u003c/b\u003e\u003c/summary\u003e\nuserHeight, userWeight 데이터를 받을 UITextField에서 키보드 내리기 기능을 추가하기 위해 이벤트를 Did End On Exit으로 설정 후 keyboardType을 decimalPad로 변경하니 입력값이 userHeight, userWeight 변수에 할당이 안 됨. 각 TextField의 IBAction 함수에 이벤트를 Editing Did End를 추가로 연결하여 해결.\n\u003c/div\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e텍스트 필드에 UserDefaults에 저장된 값을 할당했을 때 BMI 계산 안 되는 이슈\u003c/b\u003e\u003c/summary\u003e\nBMI를 계산하는 함수는 userHeight, userWeight 값으로 계산을 하는데, UserDefaults에 저장된 값을 텍스트 필드의 text에만 할당하고, userHeight와 userWeight에는 할당하지 않아 BMI 계산이 안 되는 문제 발생. viewDidLoad()에서 초기 화면 로드 시 UserDefault에 저장된 값이 기본 값(0.0)이 아닐 경우에는 텍스트 필드에 노출하고, 0.0일 경우에는 빈 문자열을 넣어주어 해결.\n\u003c/div\u003e\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev-junehee%2Fbmi-calculator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdev-junehee%2Fbmi-calculator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev-junehee%2Fbmi-calculator/lists"}