-1

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!

Albert Renshaw
  • 17,282
  • 18
  • 107
  • 195
nurnachman
  • 4,468
  • 2
  • 37
  • 40

1 Answers1

-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.

Community
  • 1
  • 1
Rikkles
  • 3,372
  • 1
  • 18
  • 24