make mac package/bundle programmatically

后端 未结 4 1978
梦谈多话
梦谈多话 2020-12-09 06:06

through terminal you can make it with a command - \"SetFile -a B filename\"

programmatically i think i should set one of the attributes through [[NSFileManager defa

4条回答
  •  攒了一身酷
    2020-12-09 06:32

    What are you trying to do?

    Almost all Mac OS X bundles are actually folders with a very specific layout of files/folders within. Rarely is a bundle just a file -- they do exist, but not often.

    In most cases, the Bundle bit on the file is entirely irrelevant.

    i want to set a folder as a bundle. so through the file system it will looks like a file. later a want to open that package with my application. the question is how to set the folder bundle attribute through cocoa.

    You really don't need to set the bundle bit. As long as your folder has an extension (which it should) and your application is properly configured to open files/folders of that extension, it should sow up in the finder as if it were a file.

    Example:

    1. Go to ~/Desktop in Finder

    2. In terminal, do:

    3. cd ~/Desktop

    4. mkdir aafoo

    5. mv aafoo aafoo.rtfd

    After (4), you'll see 'aafoo' show up in Finder as a folder.

    AFter (5), 'aafoo' will change to be a TextEdit document. No attribute bits necessary.


    OK -- fair enough. You really really want to set that bit.

    Given that you have the command line to do it, I would suggest simply using NSTask. It will likely be easier than using an API to do so.

提交回复
热议问题