Project의 General에 들어가셔서 Minimum Deployments를 16.0 보다 작은 버전으로 선택한뒤, 시뮬레이터 창을 보면 정상적으로 나와요.

그리고 나서, 다시 16.0으로 선택하시면 되요.

작성중....

 tabBar.unselectedItemTintColor = .systemCyan
 tabBar.tintColor = .systemMint
 tabBar.backgroundColor = .black

 

 

'IOS > Thoughts' 카테고리의 다른 글

Thoughts) GeoCoder.geocodeAddressString() 정확히 사용하기!  (0) 2022.09.11

안녕하세요~

 

지도 기능을 추가하면서 경험한 것을 공유하려고 해요.

 

제가 운영하는 앱은 공공데이터 API를 사용해요.

 

근데, 공공 데이터 API에서 위도와 경도 값을 제공하지 않기에, 주소를 입력받아 위도, 경도로 변환하는 과정을 수행하기 위해

위와 같은 함수를 사용해요.

 

위 함수를 사용해서, 성공적으로 지도에 위치를 그려주었어요.

(근데 혹시 버그가 있을 수도 있으니깐 다른 지역도 보았습니다.)

 

 

 

....국내에 있어야할 명심근린공원이 하노이에 있는 결과를 보게 되었어요.

 

 

그래서, 생각을 하게 되었어요.

 

실재로 로그를 찍어보니깐, 경도가 한국이랑 5도에서 6도가 차이가 나더라구요.

 

그래서, 처음에는 If 문을 사용해서 대응을 하려고 했습니다. 

 

 

If 경도<26{

 경도 + 5 
 위도 + 10 

}

 

 

실재로는 대응이 대부분 되었어요. 근데 문제는 "대부분"이라는 것이었어요.

 

그래서, 다른 방법을 모색하기로 했어요.

 

아래는 Apple 문서에서 제공하는 소스코드인데요. 다시 읽어보고 고민을 해보았는데, 아이디어가 떠오르지 않더라구요.

 

심지어, 애플에 건의를 해볼까 생각도 해보았어요 ㅎㅎ

 

 

func getCoordinate( addressString : String, 
        completionHandler: @escaping(CLLocationCoordinate2D, NSError?) -> Void ) {
    let geocoder = CLGeocoder()
    geocoder.geocodeAddressString(addressString) { (placemarks, error) in
        if error == nil {
            if let placemark = placemarks?[0] {
                let location = placemark.location!
                    
                completionHandler(location.coordinate, nil)
                return
            }
        }
            
        completionHandler(kCLLocationCoordinate2DInvalid, error as NSError?)
    }
}

 

 

그래서, 다른 메소드를 찾기 시작했어요.

그러다가 아래 메소드를 찾았는데요!

 

 

func geocodeAddressString(_ addressString: String, in region: CLRegion?, completionHandler: @escaping CLGeocodeCompletionHandler)
Submits a forward-geocoding request using the specified string and region information.

 

 

해결법을 찾은 것 같은데요!

"특별한 지역을 사용하여" 이 부분이 눈이 확들어왔습니다!!

 

그래서, 저 메소드를 활용해서 지역을 지금 사용자의 위치로 설정을 하니 성공적으로 모두 국내에 표시되었어요!

 

 

 

 

소스 코드)

    func makeAnotation(){
        
        for i in 1..<list.count{
            
            let geoCoder = CLGeocoder()
            let title = list[i].value(forKey: "spotnameforLocation") as? String
            let address = list[i].value(forKey: "addressforLocation") as! String
            let region = CLCircularRegion(center: (locationManager.location?.coordinate)!, radius: 200, identifier: "Place")
            geoCoder.geocodeAddressString(address, in: region) { [self]
                placemarks, error in
                guard let placemarks = placemarks,
                      let longtitude = placemarks.first?.location?.coordinate.longitude,
                      let latitude = placemarks.first?.location?.coordinate.latitude else {return}
                
                let annotation = CustomPointAnnotation()
                annotation.coordinate = CLLocationCoordinate2D(latitude: latitude, longitude: longtitude)
                annotation.title = title
                annotation.subtitle = address
                
                self.mapView.addAnnotation(annotation)
                
            }
        }
        
    }

 

 

좋은 하루 보내세요~ 

참고)

 

.

https://developer.apple.com/documentation/corelocation/clgeocoder/1423591-geocodeaddressstring

 

Apple Developer Documentation

 

developer.apple.com

 

'IOS > Thoughts' 카테고리의 다른 글

Thoughts) 역시.. 실기기 테스트를 해야해요.  (0) 2022.10.02

아이폰으로 핫스팟을 키고 맥북에서 와이파이로 사용하고 있었어요.

 

최근 들어, 정상 작동이 되지 않아 불편함을 겪던 중

 

운영체제 버전을 업데이트하면서 해결이 됬어요.

 

그래서, 어떤 에러가 생기면 재부팅하거나 재설치 마지막으로 업데이트를 추천드려요.

 

 

아이폰을 최신 버전으로 업그레이드하고 위와 같은 에러가 발생했어요.

 

아래와 같은 버전을 저는 가지고 있고, 서로 양립할 수 없다고 하네요!

 

그렇다면, 한가지를 올리거나 한가지를 내리면 될 것같네요.

 

저는 엑스코드 버전을 업그레이드해서 문제를 해결할께요.

 

앱을 업데이트하기위해 제안을 했지만 아래와 같은 거절을 받았어요.

 

We noticed that the app name to be displayed on the App Store and the app name displayed on the device do not sufficiently match, which makes it difficult for users to find the app they just downloaded. The app names are:

  • Name on the App Store: 확인하고 마시자
  • Name displayed on the device: CheckWater

 

결론은, 이름을 하나로 통일 해달라는 거였어요.

 

그래서, 프로젝트를 열어서 디스플레이 이름을 한글로 변경했어요.

 

왜냐하면, 저는 이 앱을 한국어를 사용하시는 분들을 위해서 처음에 제작했거든요.

 

하지만, 한국어를 모르시는 분들이 이 앱을 사용할 수 있으니, 언어 지역화를 할 계획에 있어요.

개발자는 신경 쓸것이 많다. 그러나, 운전처럼 우리는 점점 습관이 되어 신경 쓸것이 줄어 들것이다.

 

오늘은 아래와 같은 것들을 신경 쓸 것이다.

 

Oraganize

Track 

Document 

Test

Analyze

Evaluate

Decouple

Manage

 

Oraganize

작업공간이 아래 그림과 같으면, 도구를 찾다가 시간을 다 쓸 것이다.

그래서, 아래와 같이 그룹화가 필요하다.

스토리보드를 아래와 같이 하면, 한눈에 볼 수 있어. 깔끔하다.

안쓰는 기능을 담당하는 코드는 과감하게 지워라. 기록에 남겨라.

다시 정리하면,

Track

commit을 작게 작게 해라.

그래야, 흐름을 잘 파악할 수 있다.

Commit message를 잘해라.

미래의 유용하게 볼 수 있도록, 왜 commit하는지 달아라.

 다시 정리하면,

 Document

두가지의 큰 기여자는

Clarity(명쾌함 -> 확실하게 보여서 좋은(이해하기 쉬운))

Maintainability(유지)

 

추가적으로,

내 생각에는 

Code comments

Documentation

 

 

Code comments 

why i code this?

 

 

 

Documentation

and option + click 

 

정리하면,

 

Test

Unit testing

 

나는 이것의 중요성을 처음에 몰랐다. 그래도 나는 마라쉘의 지시대로 실행하였다.

그리고 나서 유닛테스트를 구현하고 나는 초록색 마크를 봤을때, 흥미를 느꼈다.

그러고 나서 나는 나중에 Struct에 어떤 것을 추가하였고 Chage를 submit하고 runtime에 아무런 issue를 받지 못했다.

 

그리고 나는 유닛 테스트를 다시 기억했다.

나는 잊어버렸다. 변경하는 것을 어떻게 Dictionary가 deserialization하고 있는지

이것을 Test가 잡았다.

 

즉, Unit Test는 내가 생각하지 못하는 에러를 잡아준다.

정리하면,

 

 

Analyze

 

네트워크를 조절해서 분석해보자.

Ref)

https://developer.apple.com/videos/play/wwdc2019/239/?time=20 

 

Great Developer Habits - WWDC19 - Videos - Apple Developer

Successful app development requires mastering a lot of different things. Discover practices you can incorporate into your development...

developer.apple.com

 

task 3,4

  1. Architect the concept of a “theme” into your game. A theme consists of a name for the theme, a set of emoji to use, a number of cards to show (which, for at least one, but not all themes, should be random), and an appropriate color to use to draw (e.g. orange would be appropriate for a Halloween theme).
  2. Support at least 6 different themes in your game.

theme을 만들자!!

Task 5

  1. A new theme should be able to be added to your game with a single line of code.

위와 같은 메세지가 생긴다면, excode가 기억을 못지우는 걸 수 도 있기에, shift + command + B = rebuild 를 해보자.

Task 6,7

  1. Add a “New Game” button to your UI which begins a brand new game. This new game should have a randomly chosen theme. You can put this button anywhere you think looks best in your UI.
  2. Show the theme’s name somewhere in your UI.

새로운 게임을 만드는 텍스트를 만들고 navigationView를 활용하여 깔끔하게 만들자.

 

Task 8

  1. Keep score in your game by giving 2 points for every match and penalizing 1 point for every previously seen card that is involved in a mismatch.

Task 9

  1. Display the score in your UI in whatever way you think looks best.

Task 10

  1. Your UI should work in portrait or landscape on any iOS device. The cards can have any aspect ratio you’d like. This probably will not require any work on your part (that’s part of the power of SwiftUI), but be sure to continue to experiment with running on different simulators in Xcode to be sure.

Extra Credit 

  1. Support a gradient as the“color” for a theme. Hint:fill()can take a gradient as its argument rather than a color.

 

 

  • Modify the scoring system to give more points for choosing cards more quickly. For example, maybe you get max(10 - (number of seconds since last card was chosen), 1) x (the number of points you would have otherwise earned or been penalized with). (This is just an example, be creative!). You will definitely want to familiarize yourself with the Date struct.

 

'IOS > Swift Lectures by Stanford University' 카테고리의 다른 글

Lecture 4 review_ part 2  (0) 2021.04.06
Lecture 4 review_ Part 1 ...32:00  (0) 2021.04.05
Lecture 3 review coding_ 3_2  (0) 2021.04.03
Lecture 3 review coding_ 3  (0) 2021.03.30
Lecture review coding _ 2  (0) 2021.03.25

 

Protocol Syntax

Basic
You can list if there are multiple protocols

 

you shold type superclass first

 

Property Requirments

simple example

Method Requirments

basic
문서랑 결과가 같음, finally은 내가 인위적으로 추가한 거임.

Mutating Method Requirements

Initializer Requirments

Class Implentations of Protocol Initializer Requirments

required. - protocol
override - superclass

Failable Initializer Requirements

failable initializer을 정의 할 수 있데 ㅎㅎ, 별로 중요하지는 않는듯, 예재가 없어☺️☺️

Protocols as Types

문서랑 값이 같음.

Delegation

어떤 권한을 가진 사람이 다른 사람에게 결정을 내릴 수 있게 하고 직접적이게 포함되는 것을 피하게 해준다 라고 하네요!! 😊😊😊

난수 결정
주사위 면과 던지는 함수

 

주사위를 준비하고 game function 준비

 

game이 시작하고 끝나는 것을 관리하는 protocol
game algorithm

 

game의 상태를 tracking 하는 class

 

game play!!

'IOS > IOS Documentation' 카테고리의 다른 글

Enumeration  (0) 2021.04.06
Initialization  (0) 2021.03.23
Methods  (0) 2021.03.22
Properties  (0) 2021.03.22
Structure and Classes  (0) 2021.03.21

1. Enum 과  optionals를 설명해주심.

enum은 문서보면 될 것 같고, optionals처음은 빈값으로 출발한다는 것을 인지하래.

 

 

2. Set Goal

1. we are gonna fix that firstIndex of matching

2. we are gomma make game, actually play the game, start maching cards. we will make variable that keeps track of this card that's face-up

 

3. optional 

original code
after

 

after

여기서, opional는 int 혹은 nil을 전달해주는데, 

교수님은 확실한 것을 좋아하신데,

그래서

IF문을 만들어서 안에다 넣어주자.!!!!! 혹시 큰 crash가 생길수 도 있으니깐, 아래와 같이 근데,,,, 문제가 생겼어...!!!
왜?? 그건 nill일 경우에 반환하는 값이 없다라는 것이야. view를 반환해야하는데,

 

 

view를 반환하는 Group을 이용하여 return 한다. 만약, index가 nill이 된다면,,,!! 어떻게 될까?? EmptyView 를 반환하게 된다. 그러면, 에러가 풀린다. 그런데, 교수님이 더 세련된 방법을 가르쳐 주신다. 다시 원점으로 가자.

 

let index값 자체에 ! 을 붙혀보자.

그러면, MemoryGame에 에러가 발생한다....!!!!!!!! 방출 시키래!!!!!!

우리는 IF를 사용하면 에러를 없앨 수 있엏ㅎㅎㅎㅎㅎㅎㅎ

이제는, memorygame에 직접으로 연결시키자.

새로운 카드를 만질때, 이것을 감지하는 변수가 필요함.

var, !cards[chosenIndex].isFaceUp,!cards[chosenIndex].isMatched를 추가 한다!!😊😊

위 같이, coding을 진행하면, 호박에 짝이 맞추어 지면, 다음으로 거미를 맞출때, 호박 위치에 카드를 클릭해도 아무런 변화를 느낄 수 없음.

 

 

4. 맞춘 것은 사라지게 하기

 

 

5. 마지막, model 손보기

교수님이 아래 음영표시를 그으시고,

에러가 생길 가능성이 있으시데, 

두곳의 상태가 있을때에,

so,

indexOfTheOneAndOnlyFaceUpCard자체에서 관리하자!!!😊😊

 

 

아래와 같이😊

newValue가 있데. 특별한 변수 이것은 nil이 될수 있데. 오직 계산된 속성안에서만 볼수 있어 이것은.

 

 

빈 배열을 만듬.

모든 인덱스카드를 만듬.

sub zero을 반환함. faceUpCardIndeces[0] 라고 해도 되지만, .first 방법도 있음.

이제, 필요없는 부분을 지우자.

origin
after

more simple code

set

 

before
after

 

get

1

 

2
3

 

for index in casrds.indices ~ append(index) 줄이기

swift 만들기
1

 

2

 

3

 

 

Ok, good let's go reivew again.😊😊😊😊

'IOS > Swift Lectures by Stanford University' 카테고리의 다른 글

Lecture 3,4  (0) 2021.05.14
Lecture 4 review_ Part 1 ...32:00  (0) 2021.04.05
Lecture 3 review coding_ 3_2  (0) 2021.04.03
Lecture 3 review coding_ 3  (0) 2021.03.30
Lecture review coding _ 2  (0) 2021.03.25

+ Recent posts