PasteBoard종류 3가지예시)대안대안 1) 앱 전환 시 pasteboard 정리하기대안 2) canPerformAction:withSender 메소드 사용 (메뉴 미사용)대안 3) Ios10에 추가된 setItems:options 메소드참고
PasteBoard
- Copy/cut 시
pasteboard
로 알려진 버퍼에 저장됨.
- 모든 애플리케이션에서 공유함.
- 현재 앱에서 복사한 데이터를 다른 앱에서도 접근 가능
- 민감 정보 복사 시 주의 필요
종류 3가지
- Gerneral pasteboard : 일반적인 copy/paste
- Find pasteboard : UISearchBar에 입력한 마지막 문자열 저장
- Ios10 이후로 공식적으로 사용 불가
- Custom pasteboard : 앱 전용 copy/cut
예시)

- 신용카드 정보 입력 후 내용 복사
Cycript
로 ContactDetails 앱에 후킹
$ Cycript –p PID
- cycript로 Pasteboard item 출력
$ [UIPasteboard generalPasteboard].items

대안
대안 1) 앱 전환 시 pasteboard 정리하기
- 현재 앱 내에서만 사용하기 원할 경우
- applicationDidEnterBackground, applicationWillTerminate 이벤트
- pasteboard.items = nil 로 설정
- 백그라운드에서 수집하는 앱은 막을 수 없지만, 데이터 수명 단축
- 다른 앱에서 복사한 것도 없앤다는 단점.
대안 2) canPerformAction:withSender 메소드 사용 (메뉴 미사용)
(BOOL)canPerformAction:(SEL)action withSender:(id)sender{ [[NSOperationQueue mainQueue] addOperationWithBlock:^{ [[UIMenuController sharedMenuController] setMenuVisible:NO animated:NO] }]; return [super canPerformAction:action withSender:sender]; }
대안 3) Ios10에 추가된 setItems:options 메소드
- 두 개의 UIPasteboardOption 로 pasteboard privacy 설정
- Pasteboard에 추가할 item과 item에 적용할 옵션 명시
localOnly 옵션
- Handoff 기능을 통해 다른 디바이스로 pasteboard 공유되는 것 방지
참고
- UIMenuController — Displays a menu with Copy, Cut, Paste, Select, and Select All commands above or below the selection.
- UIResponder — Responders implement the canPerformAction(_:withSender:) to enable or disable commands in the above-mentioned menu based on the current context.
- UIResponderStandardEditActions — Responders implement methods declared in this informal protocol to handle the chosen menu commands (for example, copy: and paste:).