Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Starfox

macrumors 6502
Original poster
Apr 7, 2011
256
9
I'm trying my hand at making a package-based document app, and I'm struggling with some things. I'm using a file wrapper, and one of the things I want to do is enable the user to edit other documents that they drag into my document - allow me to explain.

Imagine a word editing kind of app where the user drags an image into the document - in my case whenever the user drags a file that be embedded in my document, I create a new file wrapper for it. Now I want to enable the user to, say, open that image they dragged in Pixelmator or Photoshop, edit it a little, then save it with the changes immediately reflected in my document. How do I do that?

In case that matters, the actual use case has my user dragging some Collada, Blender and Lua scripting files that I want them to be able to open in preferred editor then save with changes reflected immediately in the document in my app.

Any pointers / ideas on the right way to do this? I'm familiar with C/C++ but I'm new to Mac programming so I might be missing some obvious way to do this.
 
Opening the documents in external editors should not be too bad. You have two (at least) choices here:

1) Get the external editor to open file to be edited by opening the file inside your file wrapper

2) Copy the file to temp and then open it there

Personally I'd go with 2). In the case of 1) if the external editor corrupts the file you loose the copy in your file wrapper.

As for detecting saves you can use the FSEvent API to monitor the folder the file is in for changes. Maintain an internal state of last modified time for each file in there and you can quickly check which has changed and reload it.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.