Skip to content

Commit 1f39503

Browse files
author
weichao
committed
access UI Property on main queue
1 parent c8cbad8 commit 1f39503

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

LinkMap/ViewController.m

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,12 @@ - (IBAction)analyze:(id)sender {
9191

9292
NSArray *sortedSymbols = [self sortSymbols:symbols];
9393

94-
if (_groupButton.state == 1) {
94+
__block NSControlStateValue groupButtonState;
95+
dispatch_sync(dispatch_get_main_queue(), ^{
96+
groupButtonState = _groupButton.state;
97+
});
98+
99+
if (1 == groupButtonState) {
95100
[self buildCombinationResultWithSymbols:sortedSymbols];
96101
} else {
97102
[self buildResultWithSymbols:sortedSymbols];
@@ -171,7 +176,11 @@ - (void)buildResultWithSymbols:(NSArray *)symbols {
171176
self.result = [@"文件大小\t文件名称\r\n\r\n" mutableCopy];
172177
NSUInteger totalSize = 0;
173178

174-
NSString *searchKey = _searchField.stringValue;
179+
__block NSString *searchKey;
180+
dispatch_sync(dispatch_get_main_queue(), ^{
181+
searchKey = _searchField.stringValue;
182+
});
183+
175184

176185
for(SymbolModel *symbol in symbols) {
177186
if (searchKey.length > 0) {

0 commit comments

Comments
 (0)