What is the best way to send images between the containing app and a custom keyboard? is there a best practice that apple talk about? is there a hacky way that apple will hate? is there a framework already that somebody built in github that helps this? thanks!
Asked
Active
Viewed 492 times
-1
-
Why you don't start a bounty, or if you found your solution then plz post it here – Anand Suthar Aug 20 '14 at 16:42
-
Did you find a better solution than using NSUserDefaults? – DanielZanchi Aug 15 '16 at 21:26
1 Answers
-2
You can save images in NSUserDefaults
, see Save images in NSUserDefaults? . And since you have access to NSUserDefaults
from the keyboard and the app, it works. See my answer in Can a custom keyboard extension identify a user of my companion application in any way? .
Note that in order to enable the sharing of a defaults container you have to follow Apple's docs in the App Extensions programming guide.
It's a very simple and effective solution, but I would only recommend it for a few very small images like icons, etc... Don't make NSUserDefaults
a repository for your camera photos!
If you want to do more complex data sharing, I would contend that a custom keyboard is probably not the correct structure.