CoderJackyHuang / HYBUnicodeReadable

解决打印日志对于Unicode编码不能正常显示中文的问题,只需要将文件导入工程,不需要引用,就能达到打印日志显示Unicode编码中文数据
MIT License
355 stars 102 forks source link

标哥,在iOS 5s(9.2)的模拟器、ipad(9.2)模拟器上面运行始终会崩溃 #8

Open mrhyh opened 8 years ago

CoderJackyHuang commented 8 years ago

一会更新到1.3版本,增加了过滤处理。这是AFN所引起的问题!一会尝试一下有没有解决掉。

原始邮件 发件人:ylgwhyhnotifications@github.com 收件人:CoderJackyHuang/HYBUnicodeReadableHYBUnicodeReadable@noreply.github.com 发送时间:2016年6月28日(周二) 10:16 主题:[CoderJackyHuang/HYBUnicodeReadable] 表哥,在iOS 5s的模拟器上面会一直崩溃 (#8)

unrecognized selector sent to instance 0x7fe339408bd0 2016-06-28 10:13:05.732 EF_MallDemo[4936:51278] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSURLSessionLocal tubeManager]: unrecognized selector sent to instance 0x7fe339408bd0' * First throw call stack: ( 0 CoreFoundation 0x000000010ba61c65 exceptionPreprocess + 165 1 libobjc.A.dylib 0x000000010e92ebb7 objc_exception_throw + 45 2 CoreFoundation 0x000000010ba690ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205 3 CoreFoundation 0x000000010b9bf13c __forwarding + 988 4 CoreFoundation 0x000000010b9becd8 _CF_forwarding_prep_0 + 120 5 EF_MallDemo 0x000000010a5a5025 -[NSObject(HYBUnicodeReadable) description] + 597 6 CoreFoundation 0x000000010ba0488a -[NSObject(NSObject) _copyDescription] + 42 7 CoreFoundation 0x000000010b95b40c CFStringAppendFormatCore + 9676 8 CoreFoundation 0x000000010ba41fb0 _CFStringCreateWithFormatAndArgumentsAux2 + 256 9 CFNetwork 0x000000010b59c258 NSLog + 166 10 CFNetwork 0x000000010b62896d -[NSURLSession initWithConfiguration:delegate:delegateQueue:] + 413 11 CFNetwork 0x000000010b548014 -[__NSURLSessionLocal initWithConfiguration:delegate:delegateQueue:] + 49 12 CFNetwork 0x000000010b629568 +[NSURLSession sessionWithConfiguration:delegate:delegateQueue:] + 351 13 EF_MallDemo 0x000000010a526de5 +[_AFURLSessionTaskSwizzling load] + 69 14 libobjc.A.dylib 0x000000010e930648 call_load_methods + 716 15 libobjc.A.dylib 0x000000010e933147 load_images + 231 16 ??? 0x000000010b09da81 0x0 + 4480162433 17 ??? 0x000000010b0a85a2 0x0 + 4480206242 18 ??? 0x000000010b0a843c 0x0 + 4480205884 19 ??? 0x000000010b0a86ad 0x0 + 4480206509 20 ??? 0x000000010b09dd40 0x0 + 4480163136 21 ??? 0x000000010b0a1074 0x0 + 4480176244 22 ??? 0x000000010b09d27c 0x0 + 4480160380 23 ??? 0x00007fff670177ac 0x0 + 140734921537452 24 ??? 0x00007fff6701604f 0x0 + 140734921531471 25 ??? 0x00007fff67012276 0x0 + 140734921515638 26 ??? 0x00007fff67012036 0x0 + 140734921515062 27 ??? 0x0000000000000001 0x0 + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

mrhyh commented 8 years ago

好的

mrhyh commented 8 years ago

标哥,更新到1.3了,还是会崩溃,不过是另外的错误提示了。环境 Xcode7.3.1 ipad 9.2

崩溃断点: // object if ([typeEncoding rangeOfString:@"@"].location != NSNotFound) { value = ((id (_)(id, SEL))objcmsgSend)((id)self, NSSelectorFromString(propertyName)); } else if ([typeEncoding rangeOfString:@""].location != NSNotFound) { char v = ((char * ()(id, SEL))objc_msgSend)((id)self, NSSelectorFromString(propertyName)); value = [NSString stringWithUTF8String:v]; } else if ([typeEncoding rangeOfString:@"#"].location != NSNotFound) { value = propertyName; } else if ([typeEncoding rangeOfString:@"^"].location != NSNotFound) { value = @"基本C指针"; } else { @try { value = [self valueForKey:propertyName]; #这里为空 } @catch (NSException *exception) {

  }
  @finally {
  }
}

错误提示: 2016-07-20 14:25:11.247 Risk[1300Printing description of propertyName: (NSCFString _) propertyName = 0x7be807f0 @"gridLayoutFlags" 6:223719] _mutations 2016-07-20 14:25:11.268 Risk[13006:223719] _objs 2016-07-20 14:25:11.269 Risk[13006:223719] _keys 2016-07-20 14:25:11.269 Risk[13006:223719] _used 2016-07-20 14:25:11.269 Risk[13006:223719] _kvo 2016-07-20 14:25:11.269 Risk[13006:223719] _size 2016-07-20 14:25:11.269 Risk[13006:223719] _mutations 2016-07-20 14:25:11.269 Risk[13006:223719] _objs 2016-07-20 14:25:11.270 Risk[13006:223719] _keys 2016-07-20 14:25:11.270 Risk[13006:223719] _used 2016-07-20 14:25:11.270 Risk[13006:223719] _kvo 2016-07-20 14:25:11.270 Risk[13006:223719] _size 2016-07-20 14:25:11.270 Risk[13006:223719] _mutations 2016-07-20 14:25:11.270 Risk[13006:223719] _objs 2016-07-20 14:25:11.271 Risk[13006:223719] _keys 2016-07-20 14:25:11.271 Risk[13006:223719] _used 2016-07-20 14:25:11.271 Risk[13006:223719] _kvo 2016-07-20 14:25:11.271 Risk[13006:223719] _size 2016-07-20 14:25:11.271 Risk[13006:223719] _mutations 2016-07-20 14:25:11.271 Risk[13006:223719] _objs 2016-07-20 14:25:11.271 Risk[13006:223719] _keys 2016-07-20 14:25:11.272 Risk[13006:223719] _used 2016-07-20 14:25:11.272 Risk[1302016-07-20 14:27:26.225 Risk[13006:223719] _interitemSpacing 2016-07-20 14:27:26.228 Risk[13006:223719] _lineSpacing 2016-07-20 14:27:26.228 Risk[13006:223719] _itemSize 2016-07-20 14:27:26.229 Risk[13006:223719] _estimatedItemSize 2016-07-20 14:27:26.229 Risk[13006:223719] _headerReferenceSize 2016-07-20 14:27:26.229 Risk[13006:223719] _footerReferenceSize 2016-07-20 14:27:26.230 Risk[13006:223719] _sectionInset 2016-07-20 14:27:26.230 Risk[13006:223719] data 2016-07-20 14:27:26.231 Risk[13006:223719] -[UICollectionViewFlowLayout data]: unrecognized selector sent to instance 0x7bfaa740 2016-07-20 14:27:28.854 Risk[13006:223719] ** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UICollectionViewFlowLayout data]: unrecognized selector sent to instance 0x7bfaa740' * First throw call stack: ( 0 CoreFoundation 0x02757494 exceptionPreprocess + 180 1 libobjc.A.dylib 0x05a96e02 objc_exception_throw + 50 2 CoreFoundation 0x02761253 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275 3 CoreFoundation 0x0269689d _forwarding_** + 1037 4 CoreFoundation 0x0269646e _CF_forwarding_prep_0 + 14 5 Risk 0x0088b2f9 -[NSObject(HYBUnicodeReadable) description] + 505 6 Foundation 0x036f0b7a _NSDescriptionWithLocaleFunc + 93 7 CoreFoundation 0x0262c307 CFStringAppendFormatCore + 9959 8 CoreFoundation 0x0272fc47 _CFStringCreateWithFormatAndArgumentsAux2 + 247 9 CoreFoundation 0x0274113c _CFLogvEx2 + 124 10 CoreFoundation 0x027412a0 _CFLogvEx3 + 144 11 Foundation 0x037e1d30 _NSLogv + 171 12 Foundation 0x0371a3c6 NSLog + 26 13 UIKit 0x04e7e0ae -[_UIFlowLayoutSection logInvalidSizesForHorizontalDirection:warnAboutDelegateValues:] + 194 14 UIKit 0x04e7c093 -[_UIFlowLayoutSection computeLayout] + 972 15 UIKit 0x04e202f6 __56-[UICollectionViewFlowLayout _updateItemsLayoutForRect:]_block_invoke + 441 16 CoreFoundation 0x0266c9d3 53-[NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 99 17 CoreFoundation 0x0266c0d5 -[NSArrayM enumerateObjectsWithOptions:usingBlock:] + 181 18 CoreFoundation 0x0266bf95 -[NSArray enumerateObjectsUsingBlock:] + 53 19 UIKit 0x04e20036 -[UICollectionViewFlowLayout _updateItemsLayoutForRect:] + 567 20 UIKit 0x04e2048c -[UICollectionViewFlowLayout _fetchItemsInfoForRect:] + 165 21 UIKit 0x04e190ff -[UICollectionViewFlowLayout prepareLayout] + 246 22 UIKit 0x04e3d161 -[UICollectionViewData _prepareToLoadData] + 76 23 UIKit 0x04e400c8 -[UICollectionViewData layoutAttributesForItemAtIndexPath:] + 36 24 UIKit 0x04de8603 -[UICollectionView scrollToItemAtIndexPath:atScrollPosition:animated:] + 298 25 Risk 0x00884ae5 -[HYBLoopScrollView layoutSubviews] + 549 26 UIKit 0x0451e3d4 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 810 27 libobjc.A.dylib 0x05aab059 -[NSObject performSelector:withObject:] + 70 28 QuartzCore 0x041da096 -[CALayer layoutSublayers] + 144 29 QuartzCore 0x041cd8b6 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 388 30 QuartzCore 0x041cd71a _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26 31 QuartzCore 0x041bfee7 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 317 32 QuartzCore 0x041f4847 _ZN2CA11Transaction6commitEv + 561 33 QuartzCore 0x041f5108 _ZN2CA11Transaction17observer_callbackEP19CFRunLoopObservermPv + 92 34 CoreFoundation 0x0266975e CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 30 35 CoreFoundation 0x026696be CFRunLoopDoObservers + 398 36 CoreFoundation 0x0265e868 CFRunLoopRunSpecific + 504 37 CoreFoundation 0x0265e65b CFRunLoopRunInMode + 123 38 UIKit 0x044482da -[UIApplication _run] + 540 39 UIKit 0x0444deb9 UIApplicationMain + 160 40 Risk 0x0071564a main + 138 41 libdyld.dylib 0x06940a25 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException

CoderJackyHuang commented 8 years ago

这个是合并他人代码过来引起的,我想想怎么解决先!

jsonliu commented 8 years ago

'HYBUnicodeReadable', '~> 1.1' 网络请求,我故意写错地址,或者参数弄错,打印错误崩溃,不使用你这个框架是没问题的。 2016-09-01 17:29:23.802 NetWorks[58494:736206] _httpInternal 2016-09-01 17:29:23.802 NetWorks[58494:736206] -[NSHTTPURLResponse httpInternal]: unrecognized selector sent to instance 0x7ffb61f20720 2016-09-01 17:29:23.820 NetWorks[58494:736206] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSHTTPURLResponse httpInternal]: unrecognized selector sent to instance 0x7ffb61f20720' * First throw call stack: ( 0 CoreFoundation 0x000000010d864d85 exceptionPreprocess + 165 1 libobjc.A.dylib 0x00000001108f4deb objc_exception_throw + 48 2 CoreFoundation 0x000000010d86dd3d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205 3 CoreFoundation 0x000000010d7b3cfa ___forwarding_ + 970 4 CoreFoundation 0x000000010d7b38a8 _CF_forwarding_prep_0 + 120 5 NetWorks 0x000000010d431219 -[NSObject(HYBUnicodeReadable) description] + 473 6 CFNetwork 0x000000011383015e -[NSURLResponse description] + 47 7 CFNetwork 0x0000000113830b00 -[NSHTTPURLResponse description] + 49 8 CoreFoundation 0x000000010d7f90ca -[NSObject(NSObject) _copyDescription] + 42 9 CoreFoundation 0x000000010d750c0f CFStringAppendFormatCore + 9759 10 CoreFoundation 0x000000010d792b38 CFStringAppendFormat + 184 11 CoreFoundation 0x000000010d860905 -[NSDictionaryI apply:context:] + 101 12 CoreFoundation 0x000000010d823d30 _CFErrorFormatDebugDescriptionAux + 672 13 CoreFoundation 0x000000010d8246a7 userInfoKeyValueShow + 71 14 CoreFoundation 0x000000010d860905 -[NSDictionaryI apply:context:] + 101 15 CoreFoundation 0x000000010d823d30 _CFErrorFormatDebugDescriptionAux + 672 16 CoreFoundation 0x000000010d823a85 _CFErrorCreateDebugDescription + 53 17 Foundation 0x000000010e37c163 -[NSError description] + 9 18 Foundation 0x000000010e2d5617 _NSDescriptionWithLocaleFunc + 91 19 CoreFoundation 0x000000010d750bdc CFStringAppendFormatCore + 9708 20 CoreFoundation 0x000000010d840a03 _CFStringCreateWithFormatAndArgumentsAux2 + 259 21 CoreFoundation 0x000000010d85193a _CFLogvEx2 + 154 22 CoreFoundation 0x000000010d851a9b _CFLogvEx3 + 171 23 Foundation 0x000000010e3acb1e _NSLogv + 117 24 Foundation 0x000000010e2fb822 NSLog + 152 25 NetWorks 0x000000010d3ea9f0 __30-[ViewController postRequest:]_block_invoke_3 + 96 26 NetWorks 0x000000010d3f41f7 116-[AFHTTPSessionManager dataTaskWithHTTPMethod:URLString:parameters:uploadProgress:downloadProgress:success:failure:]_block_invoke.97 + 167 27 NetWorks 0x000000010d416da9 72-[AFURLSessionManagerTaskDelegate URLSession:task:didCompleteWithError:]_block_invoke_2.150 + 201 28 libdispatch.dylib 0x0000000110e03d9d _dispatch_call_block_and_release + 12 29 libdispatch.dylib 0x0000000110e243eb _dispatch_client_callout + 8 30 libdispatch.dylib 0x0000000110e0c1ef _dispatch_main_queue_callback_4CF + 1738 31 CoreFoundation 0x000000010d7be0f9 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9 32 CoreFoundation 0x000000010d77fb99 __CFRunLoopRun + 2073 33 CoreFoundation 0x000000010d77f0f8 CFRunLoopRunSpecific + 488 34 GraphicsServices 0x0000000113225ad2 GSEventRunModal + 161 35 UIKit 0x000000010ec3af09 UIApplicationMain + 171 36 NetWorks 0x000000010d3eef9f main + 111 37 libdyld.dylib 0x0000000110e5892d start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException


不使用这个框架打印错误如下 2016-09-02 09:14:41.506 JFUpLoadVideo[60851:775227] error----------------Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set., NSUnderlyingError=0x7fcedbe21c40 {Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: bad request (400)" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7fcedbc0e580> { URL: http://192.168.0.26:8002/common-web/appMenu/findQuickMenus } { status code: 400, headers { Connection = close; "Content-Length" = 51; "Content-Type" = "text/html; charset=UTF-8"; Date = "Fri, 02 Sep 2016 01:10:18 GMT"; "Set-Cookie" = "JSESSIONID=3JSWXLRQzQMNvkdKC2QpDsHMpwnn8gxg6pfb1WrZGTGc5BJbBL25!1904550042; path=/; HttpOnly"; "X-Powered-By" = "Servlet/3.0 JSP/2.2"; } }, NSErrorFailingURLKey=http://192.168.0.26:8002/common-web/appMenu/findQuickMenus, com.alamofire.serialization.response.error.data=<52657175 69726564 20537472 696e6720 70617261 6d657465 7220276a 736f6e64 61746127 20697320 6e6f7420 70726573 656e74>, NSLocalizedDescription=Request failed: bad request (400)}}}

ldy694 commented 7 years ago

同样的问题