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 {
29 functionReference = [[NSMutableArray alloc] init];
31 NSString *helpBasedir = [NSString stringWithFormat:@"%@/help", [[NSBundle mainBundle] resourcePath]];
32 NSArray *helpFiles = [[NSFileManager defaultManager] directoryContentsAtPath:helpBasedir];
34 NSEnumerator *enumerator = [helpFiles objectEnumerator];
36 while (filename = [enumerator nextObject]) {
37 NSString *fullPath = [NSString stringWithFormat:@"%@/%@", helpBasedir, filename];
38 NSString *fileContents = [NSString stringWithContentsOfFile:fullPath];
39 NSDictionary *newEntry = [NSDictionary dictionaryWithObjectsAndKeys:filename, @"name", fileContents, @"text", nil];
40 [functionReference addObject:newEntry];
48 - (NSArray *)completionsForPartialWord:(NSString *)partialWord {
50 NSEnumerator *enumerator = [functionReference objectEnumerator];
51 NSMutableArray *completions = [NSMutableArray array];
54 while (entry = [enumerator nextObject]) {
55 NSString *name = [NSString stringWithFormat:@"%@()", [entry valueForKey:@"name"]];
56 if ([name hasPrefix:partialWord]) {
57 [completions addObject:name];
69 [functionReference release];