美文网首页MacOS
macOS开发二:常见崩溃&警告

macOS开发二:常见崩溃&警告

作者: BoomLee | 来源:发表于2021-08-05 19:50 被阅读0次

一、Crash

NSInvalidArgumentException

1.Printing description of reason:
*** -[NSURL initFileURLWithPath:]: nil string parameter
----
[NSURL fileURLWithPath:nil];

2.Printing description of reason:
*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]
-----
NSString *value = nil;
NSDictionary *dic = @{@"a": value};

3.Printing description of reason:
-[ViewController unImplementionSelector]: unrecognized selector sent to instance 0x600003693e80
----
[self performSelector:@selector(unImplementionSelector)];

4.Printing description of reason:
-[__NSCFConstantString characterAtIndex:]: Range or index out of bounds
----
NSString *aString = @"0123";
unichar c = [aString characterAtIndex:4];


5.[__NSMallocBlock__ countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x600000c5e270


6.[OS_dispatch_semaphore bytes]: unrecognized selector sent to instance 0x600001ab4f50

NSRangeException

*** -[NSBigMutableString characterAtIndex:]: Index 1 out of bounds; string length 1[
*** -[NSConcreteTextStorage attributesAtIndex:effectiveRange:]: Range or index out of bounds

NSInternalInconsistencyException

<NSTitlebarContainerView: 0x7fe7af1d7480>: invalid parameter not satisfying: !isnan(newOrigin.y)

NSGenericException

1、Printing description of reason:
*** Collection <__NSArrayM: 0x60000318e910> was mutated while being enumerated.
---
- (void)test9 {
    NSMutableArray *ma = [NSMutableArray arrayWithObjects:@"1",@"2",@"3",@"4",@"5", nil];
    for (NSString *obj in ma) {
        if ([obj isEqualToString:@"3"]) {
            [ma removeObject:@"3"];
        }
    }
}

2、

NSUncaughtSystemExceptionException

1、
- (void)test5 {
    NSError *error;
    testAutoReleaseError(&error);
}

void testAutoReleaseError(NSError **error) {
    [@[@1, @2] enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        if (idx == 0) {
            *error = [[NSError alloc] initWithDomain:@"domain" code:1 userInfo:nil];
        }
    }];
    NSLog(@"error:%@" , *error);
    
}
访问已经释放的对象

2、

二、Issue

Warning

Semantic Issue
Nullability Issue
Lexical or Preprocessor Issue
1、Non-portable path to file '"xxx.h"'; specified path differs in case from file name on disk
Value Conversion Issue
Uncategorized
Format String Issue
Deprecations
Unused Entity Issue
User-Defined Issue
ARC Semantic Issue
Block captures an autoreleasing out-parameter, which may result in use-after-free bugs
ARC Retain Cycle
Capturing 'httpCookieStore' strongly in this block is likely to lead to a retain cycle

相关文章

网友评论

    本文标题:macOS开发二:常见崩溃&警告

    本文链接:https://www.haomeiwen.com/subject/tshvvltx.html