• 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
NSSpellServer problem (``Couldn\'t contact Spell Server\'\')
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSSpellServer problem (``Couldn\'t contact Spell Server\'\')


  • Subject: NSSpellServer problem (``Couldn\'t contact Spell Server\'\')
  • From: "Øistein E. Andersen" <email@hidden>
  • Date: Thu, 11 May 2006 13:46:47 +0200

I try to build a spell server, but I am probably missing something obvious. I can choose my custom spell server from the standard spelling dialogue box, and the program is launched, but the requests do not seem to reach my delegate, and the message ``Couldn\'t contact Spell Server\'\' appears after a few seconds.

The executable is built as a foundation tool in Xcode and the following structure is created and put into ~/Library/Services/:

stavekontroll.service/Contents/MacOS/stavekontroll
stavekontroll.service/Contents/Info.plist
stavekontroll.service/Contents/version.plist
stavekontroll.service/Contents/PkgInfo

The Info.plist file contains the following:

<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\";>
<plist version=\"1.0\">
<dict>
	<key>CFBundleDevelopmentRegion</key>
	<string>English</string>
	<key>CFBundleExecutable</key>
	<string>stavekontroll</string>
	<key>CFBundleIdentifier</key>
	<string>com.øistein.stavekontroll</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>0.1</string>
	<key>CFBundleName</key>
	<string>stavekontroll</string>
	<key>CFBundlePackageType</key>
	<string>BNDL</string>
	<key>CFBundleShortVersionString</key>
	<string>0.1</string>
	<key>CFBundleSignature</key>
	<string>????</string>
	<key>CFBundleVersion</key>
	<string>0.1</string>
	<key>NSBGOnly</key>
	<string>1</string>
	<key>NSPrincipalClass</key>
	<string>stavekontroll</string>
	<key>NSServices</key>
	<array>
		<dict>
			<key>NSExecutable</key>
			<string>stavekontroll</string>
			<key>NSLanguages</key>
			<array>
				<string>no</string>
			</array>
			<key>NSPortName</key>
			<string>stavekontroll</string>
			<key>NSSpellChecker</key>
			<string>Øistein</string>
		</dict>
	</array>
</dict>
</plist>


And the source (stavekontroll.m) is as follows:

#import <Foundation/Foundation.h>

@interface Stavekontroll : NSObject
{
@private
	double x;
}
- (void)spellServer:(NSSpellServer *)sender didForgetWord:(NSString *)word inLanguage:(NSString *)language;
- (void)spellServer:(NSSpellServer *)sender didLearnWord:(NSString *)word inLanguage:(NSString *)language;
- (NSRange)spellServer:(NSSpellServer *)sender findMisspelledWordInString:(NSString *)stringToCheck language:(NSString *)language wordCount:(int *)wordCount countOnly:(BOOL)countOnly;
- (NSArray *)spellServer:(NSSpellServer *)sender suggestCompletionsForPartialWordRange:(NSRange)range inString:(NSString *)string language:(NSString *)language;
- (NSArray *)spellServer:(NSSpellServer *)sender suggestGuessesForWord:(NSString *)word inLanguage:(NSString *)language;
- (void)PRINT:(NSString *)chaine;
@end

@implementation Stavekontroll
- (void)spellServer:(NSSpellServer *)sender didForgetWord:(NSString *)word inLanguage:(NSString *)language
{
	NSLog(@\"forget\");
}

- (void)spellServer:(NSSpellServer *)sender didLearnWord:(NSString *)word inLanguage:(NSString *)language
{
	NSLog(@\"remember\");
}

- (NSRange)spellServer:(NSSpellServer *)sender findMisspelledWordInString:(NSString *)stringToCheck language:(NSString *)language wordCount:(int *)wordCount countOnly:(BOOL)countOnly
{
	NSLog(@\"2,3\");
	*wordCount = 2;
	return NSMakeRange(2,3);
}

- (NSArray *)spellServer:(NSSpellServer *)sender suggestCompletionsForPartialWordRange:(NSRange)range inString:(NSString *)string language:(NSString *)language
{
	NSLog([NSArray arrayWithObjects: @\"comp1\", @\"comp2\", nil]);
	return [NSArray arrayWithObjects: @\"comp1\", @\"comp2\", nil];
}

- (NSArray *)spellServer:(NSSpellServer *)sender suggestGuessesForWord:(NSString *)word inLanguage:(NSString *)language
{
	NSLog([NSArray arrayWithObjects: @\"sugg1\", @\"sugg2\", nil]);
	return [NSArray arrayWithObjects: @\"sugg1\", @\"sugg2\", nil];
}

- (void)PRINT:(NSString *)s
{
	NSLog(@\"Print:\");
	NSLog(s);
}
@end

int main()
{
    NSAutoreleasePool *autoreleasepool= [[NSAutoreleasePool alloc] init];
	NSLog(@\"Stavekontroll startet...\");
	NSSpellServer *aServer = [[NSSpellServer alloc] init];
    if ([aServer registerLanguage:@\"Norsk\" byVendor:@\"Oistein\"])
	{
        [aServer setDelegate:[[Stavekontroll alloc] init]];
		[[aServer delegate] PRINT:@\"test\"];
        [aServer run];
        fprintf(stderr, \"Unexpected death of Oistein SpellChecker!\\n\");
	}
    else
	{
        fprintf(stderr, \"Unable to check in Oistein SpellChecker.\\n\");
    }
	[autoreleasepool release];
	return 0;
}

Thank you in advance for your assistance.

--
Øistein E. Andersen
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSSpellServer problem (``Couldn\'t contact Spell Server\'\')
      • From: Douglas Davidson <email@hidden>
    • Re: NSSpellServer problem (``Couldn\'t contact Spell Server\'\')
      • From: Ondra Cada <email@hidden>
  • Prev by Date: Re: Subviews becoming blurry or "chopped up"
  • Next by Date: Re: Subviews becoming blurry or "chopped up"
  • Previous by thread: Re: Programmatically resizing an NSWindow based on window contents
  • Next by thread: Re: NSSpellServer problem (``Couldn\'t contact Spell Server\'\')
  • Index(es):
    • Date
    • Thread