Using UTIs to specify recognised document types

Discussion in 'Mac Programming' started by Nutter, Jun 9, 2007.

  1. Nutter macrumors 6502

    Joined:
    Mar 31, 2005
    Location:
    London, England
    #1
    I am trying to set up my app so that it will accept audio files dropped on to the application icon. I'm stuck at the first step - specifying the document types that I want to accept in my Info.plist.

    As I understand it, I can use the UTI "public.audio" to avoid having to enumerate every single supported audio format. (I'm not concerned about backwards compatibility.) To this end, I've set up a document type in Xcode's target info window, like this:

    [​IMG]

    Xcode has added the following to my Info.plist file:
    Code:
    <key>CFBundleDocumentTypes</key>
    	<array>
    		<dict>
    			<key>CFBundleTypeName</key>
    			<string>Audio</string>
    			<key>CFBundleTypeRole</key>
    			<string>Viewer</string>
    			<key>LSItemContentTypes</key>
    			<array>
    				<string>public.audio</string>
    			</array>
    			<key>LSTypeIsPackage</key>
    			<false/>
    			<key>NSPersistentStoreTypeKey</key>
    			<string>Binary</string>
    		</dict>
    	</array>
    
    Unfortunately this doesn't seem to work. I can't get my application to "darken" when I drag an audio file onto it. I have tried cleaning the project and rebuilding, but that doesn't help.

    I'm sure I'm missing something very simple, but I have no idea what. Apple's documentation on the subject isn't very helpful - the UTI documentation is quite sparse, and the documentation for setting up document types doesn't show how to use UTIs.

    :confused:
     
  2. Nutter thread starter macrumors 6502

    Joined:
    Mar 31, 2005
    Location:
    London, England
    #2
    I spent ages grappling with this, before realising that my application was accepting drops properly in the finder, just not in the dock.

    After that I decided this was a bug and gave up trying to get it to work. I went on to add a second document type (public.folder). Lo and behold! Now the dock accepts both audio file and folder drops for my application!

    This was in 10.4.9.

    Conclusion: There may be a bug in 10.4 that stops the dock from accepting drops when you specify a single document type with a UTI.
     

Share This Page