5 // Created by Marc Liyanage on 08.02.05.
6 // Copyright 2005 __MyCompanyName__. All rights reserved.
9 #import "AppDelegate.h"
11 @implementation AppDelegate
16 if (!self) return nil;
18 [self initFunctionReference];
25 - (void)initFunctionReference {
27 functionReference = [[NSMutableArray alloc] init];
29 NSString *helpBasedir = [NSString stringWithFormat:@"%@/help", [[NSBundle mainBundle] resourcePath]];
30 NSArray *helpFiles = [[NSFileManager defaultManager] directoryContentsAtPath:helpBasedir];
32 NSEnumerator *enumerator = [helpFiles objectEnumerator];
34 while (filename = [enumerator nextObject]) {
35 NSString *fullPath = [NSString stringWithFormat:@"%@/%@", helpBasedir, filename];
36 NSString *fileContents = [NSString stringWithContentsOfFile:fullPath];
37 NSDictionary *newEntry = [NSDictionary dictionaryWithObjectsAndKeys:filename, @"name", fileContents, @"text", nil];
38 [functionReference addObject:newEntry];
45 - (NSArray *)completionsForPartialWord:(NSString *)partialWord {
47 NSEnumerator *enumerator = [functionReference objectEnumerator];
48 NSMutableArray *completions = [NSMutableArray array];
51 while (entry = [enumerator nextObject]) {
52 NSString *name = [NSString stringWithFormat:@"%@()", [entry valueForKey:@"name"]];
53 if ([name hasPrefix:partialWord]) {
54 [completions addObject:name];
66 [functionReference release];