cyanzhong / xTextHandler
- воскресенье, 26 июня 2016 г. в 03:13:09
Objective-C
Xcode Source Editor Extension Toolset (Plugins for Xcode 8)
Xcode Source Editor Extension Toolset (Plugins for Xcode 8)
Xcode Source Editor Extension based tools, improve text editing experience for Xcode 8, you can extend with simple code
Thanks to: vkBeautify
<dict>
<key>XCSourceEditorCommandClassName</key>
<string>aClassName</string>
<key>XCSourceEditorCommandIdentifier</key>
<string>test.extension</string>
<key>XCSourceEditorCommandName</key>
<string>Test Extension</string>
</dict>
// Implement your modify strategy using block (you can implement as singleton dict)
// @{ @"commandIdentifier": handlerBlock }
- (NSDictionary *)handlers {
static NSDictionary *_instance;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_instance = @{
@"test.extension": ^NSString *(NSString *text) { return text; }
};
});
return _instance;
}
// Override performCommandWithInvocation like that
- (void)performCommandWithInvocation:(XCSourceEditorCommandInvocation *)invocation completionHandler:(void (^)(NSError * _Nullable nilOrError))completionHandler {
[xTextModifier select:invocation pattern:@"regex" handler:self.handlers[invocation.commandIdentifier]];
completionHandler(nil);
}
Since Xcode 8.0 beta (8S128d) is totally unstable now, you may see nothing after you build & run this project :(
Weibo: @StackOverflowError
Twitter: @cyanapps
Email: log.e@qq.com