Open pepejeria opened 9 years ago
I found the bug, and i fix it.
Bug locate in DescriptionGenerator.m
, method writeMethodToFileWithDescriptionMethod:
i think the latest OS X changed [NSAPP openFile:]'s implementation, when you call it, it cannt open the source file immediately, so you need wait util next runloop comes.
it's a simple way to fix it-- using dispatch_async:
- (void)writeMethodToFileWithDescriptionMethod:(NSString *)descriptionMethod {
[DTXcodeUtils openFile:[DTXcodeUtils getDotMFilePathOfCurrentEditFile]];
dispatch_async(dispatch_get_main_queue(), ^{
DVTSourceTextView *textView = [DTXcodeUtils currentSourceTextView];
NSString *textViewText = [textView string];
NSRange contentRange = [DTXcodeUtils getClassImplementContentRangeWithClassName:self.currentClass mFileText:textViewText];
NSRange insertRange = [DTXcodeUtils getInsertRangeWithClassImplementContentRange:contentRange];
[textView scrollRangeToVisible:insertRange];
NSString *newLinesRemoved = [[textViewText componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]] componentsJoinedByString:@" "];
NSString *textViewTextSpacesRemoved = [newLinesRemoved stringByReplacingOccurrencesOfString:@" " withString:@""];
if ([textViewTextSpacesRemoved containsString:@")description"]) {
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:@"Description method NOT generated because you already have one. Please delete existing method and try again."];
[alert runModal];
return;
} else {
[textView insertText:descriptionMethod replacementRange:insertRange];
}
});
}
OS X 10.11 and Xcode 7.01
I followed the instructions but the plugin is not working as expected, it adds the generated method to the top of the .h file:
The other issue is that the menu option will disappear if Xcode is restarted.