Skip to content

Commit fc4b7a5

Browse files
committed
add draft
1 parent 2e51501 commit fc4b7a5

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
layout: post
3+
title: "ios recursive search superview"
4+
tags: []
5+
published: false
6+
---
7+
{% include JB/setup %}
8+
9+
Swift에서 특정 superview를 찾기 위해선 여러가지 방법이 있습니다. superview의 타입이 원하는 타입인지 일치할때 까지 재귀함수를 이용하여 호출하는 방법 등이 있습니다.
10+
11+
그런 경우, 조건이 들어가면서 함수 자체가 복잡해지고, 이해하는데 살짝 쉽지 않습니다.
12+
13+
하지만 view는 superview를 알고 있기 때문에, sequence를 이용하여 특정 superview를 찾을 수 있습니다.
14+
15+
```swift
16+
for view in sequence(first: self, next: \.superview) {
17+
18+
}
19+
```

0 commit comments

Comments
 (0)