From c373ebffd70f69a2f4ec3c813e110a61f9c1d934 Mon Sep 17 00:00:00 2001 From: fenglei Date: Fri, 9 Nov 2018 18:25:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A31.=20=E8=A7=A3=E5=86=B3=20ain=20Thread?= =?UTF-8?q?=20Checker=20=E5=B4=A9=E6=BA=83=E9=97=AE=E9=A2=98,=202.=20?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=88=86=E7=BB=84=E5=88=86=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LinkMap/ViewController.m | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/LinkMap/ViewController.m b/LinkMap/ViewController.m index d62b393..92ed317 100644 --- a/LinkMap/ViewController.m +++ b/LinkMap/ViewController.m @@ -23,6 +23,8 @@ @interface ViewController() @property (strong) NSURL *linkMapFileURL; @property (strong) NSString *linkMapContent; +@property (nonatomic, assign) NSControlStateValue groupButtonState; +@property (nonatomic, copy) NSString *searchKey; @property (strong) NSMutableString *result;//分析的结果 @end @@ -45,6 +47,8 @@ - (void)viewDidLoad { 5.点击“输出文件”,得到解析后的Link Map文件 \n\ 6. * 输入目标文件的关键字(例如:libIM),然后点击“开始”。实现搜索功能 \n\ 7. * 勾选“分组解析”,然后点击“开始”。实现对不同库的目标文件进行分组"; + + _groupButton.state = NSControlStateValueOn; } - (IBAction)chooseFile:(id)sender { @@ -69,6 +73,9 @@ - (IBAction)analyze:(id)sender { return; } + self.groupButtonState = _groupButton.state; + self.searchKey = _searchField.stringValue; + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSString *content = [NSString stringWithContentsOfURL:_linkMapFileURL encoding:NSMacOSRomanStringEncoding error:nil]; @@ -91,7 +98,7 @@ - (IBAction)analyze:(id)sender { NSArray *sortedSymbols = [self sortSymbols:symbols]; - if (_groupButton.state == 1) { + if (_groupButtonState == 1) { [self buildCombinationResultWithSymbols:sortedSymbols]; } else { [self buildResultWithSymbols:sortedSymbols]; @@ -171,7 +178,7 @@ - (void)buildResultWithSymbols:(NSArray *)symbols { self.result = [@"文件大小\t文件名称\r\n\r\n" mutableCopy]; NSUInteger totalSize = 0; - NSString *searchKey = _searchField.stringValue; + NSString *searchKey = _searchKey; for(SymbolModel *symbol in symbols) { if (searchKey.length > 0) { @@ -220,7 +227,7 @@ - (void)buildCombinationResultWithSymbols:(NSArray *)symbols { NSArray *sortedSymbols = [self sortSymbols:combinationSymbols]; - NSString *searchKey = _searchField.stringValue; + NSString *searchKey = _searchKey; for(SymbolModel *symbol in sortedSymbols) { if (searchKey.length > 0) {