|
|
question about opening associated files...
|
|
|
|
Mac Elite
Join Date: Jan 2003
Location: NYC
Status:
Offline
|
|
I'm making an app that has a file type associated with it. I got that part working fine, the program can make the file (it's a package) and, when the file is double clicked, the app is opened/brought into focus. my question is, how do i read the file that was opened? Is there a function in the app that i can implement that will be called? Is there a notification that gets posted? I'm pretty new to this, so bear with me if this is a brutally easy question
Thanks,
Max
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
You really need to tell what language and frameworks you're using or nobody will know what you need to do.
If you're doing a Cocoa document-based application, this should work automatically for you by creating an instance of the appropriate document class. If not, but it's still a Cocoa application (my guess at what you're doing), you need to implement application:openFile: in your application's delegate.
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Jan 2003
Location: NYC
Status:
Offline
|
|
Originally posted by Chuckit:
You really need to tell what language and frameworks you're using or nobody will know what you need to do.
If you're doing a Cocoa document-based application, this should work automatically for you by creating an instance of the appropriate document class. If not, but it's still a Cocoa application (my guess at what you're doing), you need to implement application:openFile: in your application's delegate.
whoops, sorry. yeah, it's Cocoa/Obj-C, but not document-based. I'll give application:openFile a try.
thanks,
Max
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Jan 2003
Location: NYC
Status:
Offline
|
|
well i tried using application:openFile: but it doesn't seem to work, unless i missed something. The method is this:
Code:
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
{
NSLog(@"Filename: %@", filename);
return YES;
}
but this just never runs, whether i double click on the file, or drag it over the dock icon. It also doesn't make a difference whether the app was open beforehand, or if this opens the app. did i miss something obvious, or is there something else i should do?
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
You made an instance of that class your application's delegate, right?
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Jan 2003
Location: NYC
Status:
Offline
|
|
Originally posted by Chuckit:
You made an instance of that class your application's delegate, right?
oh... no, i don't believe i did (that i know of). how do i go about doing this?
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
Simplest way: Instantiate the class in Interface Builder and connect the application's "delegate" outlet to that instance.
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Jan 2003
Location: NYC
Status:
Offline
|
|
Originally posted by Chuckit:
Simplest way: Instantiate the class in Interface Builder and connect the application's "delegate" outlet to that instance.
Both the 'Window' and 'File Owner' instances in IB have delegate outlets, but neither work when connected to the class... is there a different one that i should be connecting? (there's no Application instance... should i subclass NSApplication and instantiate that?)
edit: tried to instantiate a subclass of NSApplication, doesn't let me...
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: May 2002
Status:
Offline
|
|
File Owner is the one you want, I think.
|
[vash:~] banana% killall killall
Terminated
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Jan 2003
Location: NYC
Status:
Offline
|
|
ok, File Owner worked. i tried it before and it wasn't working, but i figured out that for some reason it only works from the produced .app, not from the 'build and run' button. thanks for your help
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Jan 2003
Location: NYC
Status:
Offline
|
|
another quick question... how do i put unicode characters in the string? promoting the file to unicode causes all sorts of errors (thousands of them, in fact). in the InfoPlist.strings you can put in unicode characters with \U00A9 (for example) and it works fine, but in regular NSStrings an 'unknown escape sequence' warning comes up and the string just shows 'U00A9'. if i change the encoding of the string to UTF8 or Unicode, the same things happens.
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
Just type in the characters. If they don't have a key combination, you can use the Unicode Hex Input method method.
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Jan 2003
Location: NYC
Status:
Offline
|
|
Originally posted by Chuckit:
Just type in the characters. If they don't have a key combination, you can use the Unicode Hex Input method method.
except source files aren't encoded with unicode (and promoting them to unicode screws it up completely) so inserting the characters directly isn't an option. I'm not familiar with the hex input method, though... how does that work?
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Nov 2001
Location: State of Denial
Status:
Offline
|
|
The hex input allows you to hold down the Option key and type a sequence of four hex digits to display a character (as long as you have "Unicode Hex Input" in your keyboard menu and it's selected). For example: hold option, and press 2, 6, 0, 5 to type a black star.
This just displays the characters as usual though, so you'd need to promote to Unicode to display them...which as was said before doesn't work for source files. One thing you can do is put phrases that need extended Unicode chars into Localizable.strings and call NSLocalizedString() where you need the string displayed in the source...
|
[Wevah setPostCount:[Wevah postCount] + 1];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|