ios개발/프로젝트

<ios프로젝트2> prepare vs 메모리에 직접 저장(객체)

studying develop 2020. 3. 22. 15:59

prepare는 한 뷰컨트롤러에서 다른 뷰컨으로 넘겨주는건데, 음 이게 한 객체에서 다른 객체로 넘겨주는 개념인거 같은데

 

그럼 한 뷰컨에서 다른 모델에 저장했다가 다른 뷰컨에서 저장한 모델 값을 가져오는거랑 결과는 같고, 원리도 같은건가??

 

 


Instance Method

prepare(for:sender:)

Notifies the view controller that a segue is about to be performed.

 

음 근데 문서를 읽어보니, 디폴트는 미리 준비하는 목적이 아니라 어쨋든 해당 새그가 일어나기 전에 호출되는 개념이다.

 

Discussion

The default implementation of this method does nothing. Subclasses override this method and use it to configure the new view controller prior to it being displayed. The segue object contains information about the transition, including references to both view controllers that are involved.

 

그리고 세그 객체는 양쪽 뷰컨에 대한 참조와 함께 화면 이동에 대한 정보를 얻는다,

 

Because segues can be triggered from multiple sources, you can use the information in the segue and sender parameters to disambiguate(모호하지 않게한다) between different logical paths in your app. For example, if the segue originated from a table view, the sender parameter would identify the table view cell that the user tapped. You could then use that information to set the data on the destination view controller.

 

아 이부분이 프리페어와, 세그의 중요 요점 포인트 같다. 세그는 다양한 소스로 부터 트리거 될 수 있다, 세그안의 정보와 센더(세그를 트리거하는 뷰컨인듯)를 이용해 서로 다른 논리적 패스들이 앱에서 명확할 수 있게 해준다. 예를들면 뷰테이블에서 세그가 향하면, 센더 인자는 유저가 누르는 테이블 뷰 셀을 식별한다. 그리고 나서 우리는 정보를 도착 지점 뷰컨에 셋할 수 있게 한다.

 

즉 세그는 논리적 전환에 대한 기본 단위 같습니다. 단순히 이동하는 메소드를 넘어