Hi Every Friend,

   In my app, my purpose is to limit the media type to the .mp3 and .aiff 

only when I drag files into a table view. Other type is not allowed.





  The code fragment is to limit the media type to mp3 and .aiff.  When I

drag file into table view, MP3 file is OK. But the .aiff file can not be

drop into the table view. 

  I spent so much time but it is not useful. Could any body look over

the code for me and help me to solve it?




  Thank you!! I will wait for your answer all the time. 

Wish you good luck.




This is my code:




- (BOOL)isFileUTIMP3:(NSString *)filePath 

{

    BOOL isMP3File = NO,isAIFFFile=NO;

    FSRef fileRef;

    Boolean isDirectory;

    if (FSPathMakeRef((constUInt8 *)[filePath fileSystemRepresentation], 
&fileRef, &isDirectory) == noErr)

    {

        CFDictionaryRef values = NULL;

        CFStringRef attrs[1] = { kLSItemContentType };

        CFArrayRef attrNames = CFArrayCreate(NULL, (constvoid **)attrs, 1, 
NULL);

        if (LSCopyItemAttributes(&fileRef, kLSRolesViewer, attrNames, &values) 
== noErr)

        {

            if (values != NULL)

            {

                CFTypeRef uti = CFDictionaryGetValue(values, 
kLSItemContentType);

                if (uti != NULL)

                {

if (UTTypeConformsTo(uti, kUTTypeMP3)) 

{ isMP3File = YES; }

else 

{ if(UTTypeConformsTo(uti, CFSTR("public.aiff-audio")))

 isMP3File = YES;

}

                CFRelease(values);

               }

         }

        CFRelease(attrNames);

    }

}

    return isMP3File;

}




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to