Re: NSService - I need a headslap
Re: NSService - I need a headslap
- Subject: Re: NSService - I need a headslap
- From: Steve Cronin <email@hidden>
- Date: Wed, 04 Feb 2009 17:07:51 -0600
Peter;
I think I may have found into the core issue for me:
I don't have a xib file in this stand-alone app.
In main.m the invocation of NSApplicationMain() is equivalent to:
void NSApplicationMain(int argc, char *argv[]) {
[NSApplication sharedApplication];
[NSBundle loadNibNamed:@"myMain" owner:NSApp];
[NSApp run];
}
As you can see from my Info.plist sent earlier I don’t have ‘Main nib
file base name’ set.
Could this cause the whole app to just go plunk?
Would I need to subclass NSApplication instead of NSObject here?
(Yikes that sound BIG?) (I’d need to switch out Principal Class in
Info.plist to be MyService, yes?)
What would main.m need to look like then?
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
freopen([[NSHomeDirectory() stringByAppendingPathComponent:@"Library/
Logs/com.myCompany.MyService.log"] fileSystemRepresentation], "w",
stderr);
[pool release];
[MyService sharedApplication];
return [NSApp run];
}
I’m willing to bet that the above is NOT right!
On the whole would it just be easier to add a xib with nothing in it?
Seems kinda wonky....
My gut tells me that this is where I am going wroing!
Steve
On Feb 4, 2009, at 2:37 PM, Peter Ammon wrote:
Hi Steve,
What appears in the Services menu is entirely determined by the
NSServices portion of your Info.plist. If you post that to the
list, we can look for any problems.
Your Service is launched on-demand when the user selects it from the
menu. Services may be background only, but do not have to be.
On Tiger and earlier, there is no way to avoid needing to log in and
out. On Leopard, you can use the function NSUpdateDynamicServices()
to immediately scan for new Services. If you're just testing, a
quick way to scan for new Services is to run pbs directly:
/System/Library/CoreServices/pbs
However, pbs has no supported public interface and this will (has
already) change, so don't include any reference to pbs in a script.
NSUpdateDynamicServices() is the right way to programmatically
refresh Services.
-Peter
On Feb 4, 2009, at 7:03 AM, Steve Cronin wrote:
Well, sheesh - that's embarrassing! There is no 'self' until init
- I know that! Ugh.
However, that doesn't change my end result!
I never see anything on the Services menu nor anything from the
NSLog statements shown below.
(Even when I double-click on the .service file; after whcih I CAN
see it in the process list in Activity monitor but still no log
messages)
Logging out and back in doesn't make my service name appear on the
Service menu...
This is on a 10.5.6 system using a Release build which has been
placed in ~/Library/Services.
SO my basic questions still stand:
What event/conditions launches a .service which resides in ~/
Library/Services?
Should/must .service files be 'Background Only'?
Am I missing something basic in my setup here -
I have only a Info.plist and 1 .h (NSObject) and 2 . m files (main
and MyService) and no .xib?
Other than the 'wrapper' settings are there other compiler settings
required for this setup?
I have only 2 steps in my build process: 'Compile Source (2)' and
'Link Binary w/ Lib (1)' [Cocoa]
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden