Post

Replies

Boosts

Views

Activity

i recieved many crash after i received pasteboard content changed notification
i recieved many crash after i received pasteboard content changed notification. i just monitor the change of pasteboard, and try to recognize the text content.here is my code: class PasteboardMonitor { init() { addPasteboardMonitor() } func addPasteboardMonitor() { handleContentFromPasteBoard(conent: UIPasteboard.general.string, identifier: "\(UIPasteboard.general.changeCount)") NotificationCenter.default.addObserver(self, selector: #selector(didReceivedPasteboardNotification(noti:)), name: UIPasteboard.changedNotification, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(didReceivedPasteboardNotification(noti:)), name: UIApplication.willEnterForegroundNotification, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(didReceivedApplicationNotification), name: UIApplication.willResignActiveNotification, object: nil) } func handleContentFromPasteBoard(conent: String?, identifier: String? = nil) { //handle content ... } @objc func didReceivedPasteboardNotification(noti: Notification) { handleContentFromPasteBoard(conent: UIPasteboard.general.string, identifier: "\(UIPasteboard.general.changeCount)") }the crash log is: Crashed: com.apple.UIKit.pasteboard.cache-queue 0 libsystem_pthread.dylib 0x1963b5a38 ___chkstk_darwin + 64 1 libdispatch.dylib 0x19635f49c _dispatch_mach_send_and_wait_for_reply + 440 2 libdispatch.dylib 0x19635f904 dispatch_mach_send_with_result_and_wait_for_reply + 56 3 libxpc.dylib 0x19629f594 xpc_connection_send_message_with_reply_sync + 240 4 Foundation 0x196ba51fc __NSXPCCONNECTION_IS_WAITING_FOR_A_SYNCHRONOUS_REPLY__ + 16 5 Foundation 0x19696b090 -[NSXPCConnection _sendInvocation:orArguments:count:methodSignature:selector:withProxy:] + 2704 6 Foundation 0x19696a40c -[NSXPCConnection _sendSelector:withProxy:arg1:] + 128 7 Foundation 0x196bac2ac _NSXPCDistantObjectSimpleMessageSend1 + 40 8 Pasteboard 0x1ac476aac -[PBServerConnection localGeneralPasteboard:] 9 UIKitCore 0x19a6c3428 _getTemporaryLocalGeneralPasteboard + 64 10 UIKitCore 0x19a6c2444 _pasteboardCacheQueue_existingItemCollectionWithName + 152 11 UIKitCore 0x19a6c2160 __59+[_UIConcretePasteboard _pasteboardNamed:createIfNotFound:]_block_invoke + 236 12 libdispatch.dylib 0x196349fd8 _dispatch_client_callout + 20 13 libdispatch.dylib 0x1963567f4 _dispatch_lane_barrier_sync_invoke_and_complete + 60 ... 218 UIKitCore 0x19a6c1fcc +[_UIConcretePasteboard _pasteboardNamed:createIfNotFound:] + 396 219 TovApp 0x1014e4a54 PasteboardMonitor.didReceivedPasteboardNotification(noti:) + 123 (PasteboardMonitor.swift:123) 220 TovApp 0x1014e4c4c @objc PasteboardMonitor.didReceivedPasteboardNotification(noti:) + 4351249484 (<compiler-generated>:4351249484) 221 Foundation 0x196a6effc __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_2 + 28 222 CoreFoundation 0x1965fc99c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 28 223 CoreFoundation 0x1965fc9ec ___CFXRegistrationPost1_block_invoke + 68 224 CoreFoundation 0x1965fbce4 _CFXRegistrationPost1 + 396 225 CoreFoundation 0x1965fb97c ___CFXNotificationPost_block_invoke + 108 226 CoreFoundation 0x196574910 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1424 227 CoreFoundation 0x1965fb2ac _CFXNotificationPost + 1268 228 Foundation 0x19695db8c -[NSNotificationCenter postNotificationName:object:userInfo:] + 64 229 UIKitCore 0x19a6c1cd4 _sendPasteboardChangedNotification + 96 230 UIKitCore 0x19a6c1fcc +[_UIConcretePasteboard _pasteboardNamed:createIfNotFound:] + 396 231 TovApp 0x1014e4a54 PasteboardMonitor.didReceivedPasteboardNotification(noti:) + 123 (PasteboardMonitor.swift:123) 232 TovApp 0x1014e4c4c @objc PasteboardMonitor.didReceivedPasteboardNotification(noti:) + 4351249484 (<compiler-generated>:4351249484) 233 Foundation 0x196a6effc __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_2 + 28 234 CoreFoundation 0x1965fc99c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 28 235 CoreFoundation 0x1965fc9ec ___CFXRegistrationPost1_block_invoke + 68 236 CoreFoundation 0x1965fbce4 _CFXRegistrationPost1 + 396 237 CoreFoundation 0x1965fb97c ___CFXNotificationPost_block_invoke + 108 238 CoreFoundation 0x196574910 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1424 239 CoreFoundation 0x1965fb2ac _CFXNotificationPost + 1268 240 Foundation 0x19695db8c -[NSNotificationCenter postNotificationName:object:userInfo:] + 64 241 UIKitCore 0x19a6c1cd4 _sendPasteboardChangedNotification + 96 242 UIKitCore 0x19a6c1fcc +[_UIConcretePasteboard _pasteboardNamed:createIfNotFound:] + 396 243 TovApp 0x1014e4a54 PasteboardMonitor.didReceivedPasteboardNotification(noti:) + 123 (PasteboardMonitor.swift:123) 244 TovApp 0x1014e4c4c @objc PasteboardMonitor.didReceivedPasteboardNotification(noti:) + 4351249484 (<compiler-generated>:4351249484) 245 Foundation 0x196a6effc __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_2 + 28 246 CoreFoundation 0x1965fc99c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 28 247 CoreFoundation 0x1965fc9ec ___CFXRegistrationPost1_block_invoke + 68 248 CoreFoundation 0x1965fbce4 _CFXRegistrationPost1 + 396 249 CoreFoundation 0x1965fb97c ___CFXNotificationPost_block_invoke + 108 250 CoreFoundation 0x196574910 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1424 251 CoreFoundation 0x1965fb2ac _CFXNotificationPost + 1268 252 Foundation 0x19695db8c -[NSNotificationCenter postNotificationName:object:userInfo:] + 64 253 UIKitCore 0x19a6c1cd4 _sendPasteboardChangedNotification + 96 254 UIKitCore 0x19a6c1fcc +[_UIConcretePasteboard _pasteboardNamed:createIfNotFound:] + 396 255 TovApp 0x1014e4a54 PasteboardMonitor.didReceivedPasteboardNotification(noti:) + 123 (PasteboardMonitor.swift:123)do anybody know why this occurs? and how to fix it? thanks.
0
0
960
May ’20
iOS13 UIPasteboard.general.changeCount increase 2 after UITextfield become first responder
from iOS13, UIPasteboard.general.changeCount increase 2 after UITextfield become first responder in my demo project that just contain a viewcontroller with a UITextfield. but this just happen in my project, but system application haven't this problem. how can i solve this problem?the demo code as following:@interface ViewController () @property (nonatomic, strong) UITextField *text; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveNoti:) name:UIApplicationWillEnterForegroundNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveNoti:) name:UIApplicationWillResignActiveNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveNoti:) name:UIApplicationDidBecomeActiveNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveNoti:) name:UIApplicationDidEnterBackgroundNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveNoti:) name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveNoti:) name:UIPasteboardChangedNotification object:nil]; _text = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 200, 50)]; _text.borderStyle = UITextBorderStyleRoundedRect; [self.view addSubview:_text]; _text.center = [self.view center]; _text.delegate = self; self.view.backgroundColor = [UIColor lightGrayColor]; } -(void)didReceiveNoti: (NSNotification *)noti{ if (_text.isFirstResponder) { NSLog(@"text is first responder"); } NSLog(@"%@:%@--%ld",[noti name],[UIPasteboard generalPasteboard].string,[UIPasteboard generalPasteboard].changeCount); } -(BOOL)textFieldShouldBeginEditing:(UITextField *)textField{ return YES; } -(void)textFieldDidBeginEditing:(UITextField *)textField{ NSLog(@"Begin: %@--%ld",[UIPasteboard generalPasteboard].string,[UIPasteboard generalPasteboard].changeCount); } -(BOOL)textFieldShouldReturn:(UITextField *)textField{ [self.view endEditing:YES]; return YES; } -(void)textFieldDidEndEditing:(UITextField *)textField{ NSLog(@"End: %@--%ld",[UIPasteboard generalPasteboard].string,[UIPasteboard generalPasteboard].changeCount); } @endthe logs as follow:2020-04-13 16:31:55.297575+0800 test-ios[3755:876456] UIApplicationWillEnterForegroundNotification:Copyright--72132 2020-04-13 16:31:55.315226+0800 test-ios[3755:876456] UIApplicationWillEnterForegroundNotification:Copyright--72132 2020-04-13 16:31:55.343921+0800 test-ios[3755:876456] UIApplicationDidBecomeActiveNotification:Copyright--72132 2020-04-13 16:31:55.353844+0800 test-ios[3755:876456] UIApplicationDidBecomeActiveNotification:Copyright--72132 2020-04-13 16:31:59.140726+0800 test-ios[3755:876456] Begin: Copyright--72132 2020-04-13 16:31:59.276366+0800 test-ios[3755:876456] UIKeyboardWillShowNotification:Copyright--72132 2020-04-13 16:31:59.276500+0800 test-ios[3755:876456] text is first responder 2020-04-13 16:31:59.295168+0800 test-ios[3755:876456] UIKeyboardWillShowNotification:Copyright--72132 2020-04-13 16:31:59.673213+0800 test-ios[3755:876456] UIKeyboardWillShowNotification:Copyright--72134 2020-04-13 16:31:59.673338+0800 test-ios[3755:876456] text is first responder 2020-04-13 16:31:59.686831+0800 test-ios[3755:876456] UIKeyboardWillShowNotification:Copyright--72134 2020-04-13 16:31:59.714956+0800 test-ios[3755:876456] UIKeyboardWillShowNotification:Copyright--72134 2020-04-13 16:31:59.715068+0800 test-ios[3755:876456] text is first responder 2020-04-13 16:31:59.725141+0800 test-ios[3755:876456] UIKeyboardWillShowNotification:Copyright--72134 2020-04-13 16:32:32.902285+0800 test-ios[3755:876456] End: Copyright--72134 2020-04-13 16:32:36.060443+0800 test-ios[3755:876456] Begin: Copyright--72134 2020-04-13 16:32:36.096412+0800 test-ios[3755:876456] UIKeyboardWillShowNotification:Copyright--72134 2020-04-13 16:32:36.096522+0800 test-ios[3755:876456] text is first responder 2020-04-13 16:32:36.105762+0800 test-ios[3755:876456] UIKeyboardWillShowNotification:Copyright--72134 2020-04-13 16:32:39.273601+0800 test-ios[3755:876456] End: Copyright--72136as it showing, everytime textfield become first responder, pasteboard's chagecount increase,but i don't receive any notification about pasteboard's content changed
4
0
917
Apr ’20