LoginSignup
0
1

More than 5 years have passed since last update.

UIPasteboard.generalPasteboard()

Last updated at Posted at 2016-11-23

Pasteboardで色々実験してて詰まった。

どのアプリからでも共通で使えるgeneralPasteboardの中身を使おうとしていて
UIPasteboard.generalPasteboard().hasStrings
の値をチェックしてtrueの時に何かしら処理をしたい。

ただ、シミュレータだと、アプリ上でもバックグラウンドでも、
UIPasteboard.generalPasteboard().hasStringsがtrueの場合は、UIPasteboard.generalPasteboard().stringで文字列取得できるのに、
実機でテストしてみると、バックグラウンドで実行した時、UIPasteboard.generalPasteboard().hasStringsがtrueなのに.stringでnilが返ってきてしまう。

何が問題なのか結構調べてみたがわからず。(developper forum見てたら仕様っぽい感じだけど、正確なところわからない)

  1. セキュリティ的な仕様
  2. バックグラウンド実行の時には何か別のところから取得しなければいけない
  3. 実機で想定した値を取得するには何かしらの設定が必要

どなたか知っていたらご教示くださいmm

0
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1