Subclasses implement the actual completion logic for MOCompletionManager.
MOCompletionStrategy is an abstract superclass. Subclasses of MOCompletionStrategy are used to define the actual completion behavior for a MOCompletionManager. MOCompletionStrategy subclasses must override one method and may optionally override a second as well. The required method to override is -matchesForPrefixString:newPrefixString:basePath: which should return the possible completions for the given prefix string. MOCompletionStrategy subclasses that need to glue together the prefix and the completions is special ways can override -fullStringForPrefixString:completionString:isInitialPrefixMatch:basePath: to do something more clever than simply appending the completion to the prefix.
fullStringForPrefixString:completionString:isInitialPrefixMatch:basePath: |
- ( NSString *) fullStringForPrefixString: (NSString *) prefixStr completionString: (NSString *) completionStr isInitialPrefixMatch: (BOOL ) initialPrefixMatch basePath: (NSString *) basePath;
This method is responsible for creating the full string given a prefix string and a completion. The default implementation simply appends the completion string to the prefix string. Subclasses can override to do trickier kinds of combining.
- prefixStr
- The prefix string.
- completionStr
- The completion string (this is always one of the strings returned from a previous call to -matchesForPrefixString:newPrefixString:basePath:).
- initialPrefixMatch
- This is YES if the composition is being done on the prefix and the longest common prefix of all the possible completions. It is NO otherwise. Some subclasses may alter their behavior based on this information.
- basePath
- In general user-defined info passed in to MOCompletionManager and passed along to the MOCompletionStrategy. In practice this is often a path that is used for path-based completion as a base for evaluating relative paths.
matchesForPrefixString:newPrefixString:basePath: |
- ( NSArray *) matchesForPrefixString: (NSString *) str newPrefixString: (NSString **) newStr basePath: (NSString *) basePath;
This is the primary method that a MOCompletionStrategy must override. Given a prefix string and a base path (which is basically user-defined info passed in from the client of the MOCompletionManager), this method is responsible for figuring out possible completions and returning them in an array. The completion strings returned should not include the prefix. Composing the prefix with a possible completion is done separately.
- str
- The prefix string that completions should be done against.
- newStr
- A pointer to an NSString pointer. If the MOCompletionStrategy wants to modify the prefix string, it can do so by passing a new prefix string back through this pointer. If a MOCompletionStrategy does not assign into this pointer, the prefix string is left unchanged.
- basePath
- In general user-defined info passed in to MOCompletionManager and passed along to the MOCompletionStrategy. In practice this is often a path that is used for path-based completion as a base for evaluating relative paths.
(Last Updated 3/20/2005)