You're still instantiating every handler class just to see whether one applies
to a given file.
This is exactly why class methods exist: You can implement a class method on
your handler classes like "Can this handler class be used for files of this
type?" Then, for the class answers yes, that'
Thanks for the input everyone.
For those curious, this is the final code:
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString
*)filename
{
NSError *err = nil;
NSString *utiFile = [[NSWorkspace sharedWorkspace] typeOfFile:filename
error:&err];
if (err) {
On Dec 18, 2011, at 3:14 AM, Ken Thomases wrote:
> On Dec 18, 2011, at 3:06 AM, Charles Srstka wrote:
>
>> On Dec 18, 2011, at 2:49 AM, Ken Thomases wrote:
>>
>>> On Dec 18, 2011, at 2:36 AM, Charles Srstka wrote:
>>>
On Dec 18, 2011, at 2:31 AM, C.W. Betts wrote:
> So I would do
On Dec 18, 2011, at 2:36 AM, Charles Srstka wrote:
> On Dec 18, 2011, at 2:31 AM, C.W. Betts wrote:
>
>> So I would do something along the lines of [NSArray
>> arrayWithObjects:ClassName1, ClassName2, nil]?
>
> Or just class1, class2, etc. where class1 and class2 are both of type Class.
You ca
On Dec 18, 2011, at 2:31 AM, C.W. Betts wrote:
> So I would do something along the lines of [NSArray
> arrayWithObjects:ClassName1, ClassName2, nil]?
Or just class1, class2, etc. where class1 and class2 are both of type Class.
Charles___
Cocoa-dev ma
So I would do something along the lines of [NSArray
arrayWithObjects:ClassName1, ClassName2, nil]?
On Dec 17, 2011, at 9:51 PM, Chris Hanson wrote:
> On Dec 17, 2011, at 6:02 PM, C.W. Betts wrote:
>
>> Is there a way to put classes into some sort of array to go through and
>> check if the UTI o
On Dec 17, 2011, at 11:13 PM, Charles Srstka wrote:
> Chris already answered your main question, but I’d just like to add that it’s
> probably better to use UTTypeConformsTo() instead of UTTypeEqual() to test
> UTIs. This way, in the hypothetical case that you encounter a subtype of one
> of th
On Dec 17, 2011, at 8:02 PM, C.W. Betts wrote:
> This is how I have my code set up: an Objective-C protocol that has a class
> function that returns an NSArray of UTIs that it can handle, and a member
> function that handles the file type:
>
> @protocol PcsxrFileHandle
>
> + (NSArray *)utisCa
On Dec 17, 2011, at 6:02 PM, C.W. Betts wrote:
> Is there a way to put classes into some sort of array to go through and check
> if the UTI of a file matches up to any of the UTIs that the class can handle?
Classes are objects too, so you can put them in arrays and so on.
-- Chris
__
This is how I have my code set up: an Objective-C protocol that has a class
function that returns an NSArray of UTIs that it can handle, and a member
function that handles the file type:
@protocol PcsxrFileHandle
+ (NSArray *)utisCanHandle;
- (BOOL)handleFile:(NSString *)theFile;
@end
Howeve
10 matches
Mail list logo