• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSOpenPanel runModalForTypes: trouble (was: lowercaseString on Jaguar)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSOpenPanel runModalForTypes: trouble (was: lowercaseString on Jaguar)


  • Subject: Re: NSOpenPanel runModalForTypes: trouble (was: lowercaseString on Jaguar)
  • From: Stephane Sudre <email@hidden>
  • Date: Wed, 16 Jun 2004 14:19:05 +0200

On mercredi, juin 16, 2004, at 12:42 PM, Michael Becker wrote:

Hi!

I found the ACTUAL problem. NSOpenPanel's runModalForDirectory:file:types: takes an NSArray for the 'filetypes' parameter. However, it seems to be case-sensitive on 10.2.8, whereas it is case-insensitive on 10.3.
I want people to only load JPEG-Images, do I have to provide an array with all possible versions of capitalization of the words 'JPG' and 'JPEG'? Or is there something I am missing?

#import "MainController.h"

@implementation MainController

- (void) awakeFromNib
{
NSOpenPanel * tOpenPanel;

tOpenPanel=[NSOpenPanel openPanel];

[tOpenPanel setDelegate:self];

[tOpenPanel runModalForDirectory:nil file:nil types:nil];
}

- (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename
{
static NSFileManager * sFileManager=nil;
NSDictionary * tDictionary;

if (sFileManager==nil)
{
sFileManager=[NSFileManager defaultManager];
}

tDictionary=[sFileManager fileAttributesAtPath:filename traverseLink:YES];

if (tDictionary!=nil)
{
NSString * tFileType;

tFileType=[tDictionary objectForKey:NSFileType];

if ([tFileType isEqualToString:NSFileTypeDirectory]==YES)
{
return YES;
}
else if ([tFileType isEqualToString:NSFileTypeRegular]==YES)
{
NSNumber * tFileTypeCode;
NSString * tFileExtension;

tFileTypeCode=[tDictionary objectForKey:NSFileHFSTypeCode];

if (tFileTypeCode!=nil)
{
if ([tFileTypeCode unsignedLongValue]=='JPEG')
{
return YES;
}
}

tFileExtension=[filename pathExtension];

if ([tFileExtension caseInsensitiveCompare:@"JPEG"]==NSOrderedSame ||
[tFileExtension caseInsensitiveCompare:@"JPG"]==NSOrderedSame)
{
return YES;
}

// If you really want to, you can also check the Magic cookie at the beginning of the JPEG file if there's any.

// To be continued
}
}

return NO;
}

@end
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >NSOpenPanel runModalForTypes: trouble (was: lowercaseString on Jaguar) (From: Michael Becker <email@hidden>)

  • Prev by Date: Re: Defining a constant as private
  • Next by Date: Re: using SystemConfiguration framework
  • Previous by thread: NSOpenPanel runModalForTypes: trouble (was: lowercaseString on Jaguar)
  • Next by thread: Compile problem with xcode
  • Index(es):
    • Date
    • Thread