Objective-C crash

I check self.next_id is not null, why is this line error? I am unable to reproduce the problem on my test devices. I am getting crash reports from Crashlytics on this line.

-(Second*)getNextSecond:(BOOL)returnSelf{
    Second* retValue = nil;

    if(self.next_id){
        //this line !!!!
        retValue = [[SecondDatabase sharedManager] getSecond:[self.next_id stringValue]];
    }

    if (retValue == nil && returnSelf) {
        return self;
    }else{
        return retValue;
    }
     }

      

This is my sharedManager SecondDatabase function:

@property NSMutableDictionary* dictionary;
- (id)init {
    if (self = [super init]) {
         _dictionary = [@{} mutableCopy];
    }
    return self;
}

+ (id)sharedManager {
    static SecondDatabase *sharedMyManager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedMyManager = [[self alloc] init];
    });
    return sharedMyManager;
}

      

This is my getSecond function:

-(Second*)getSecond:(NSString*)idString{
    return [_dictionary objectForKey:idString];
}

      

Where should I investigate? Would it crash if the dictionary doesn't have an object for the key to return NULL?

My crash report:

Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0x000007d8

Thread : Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x3acd164c realizeClass(objc_class*) + 19
1  libobjc.A.dylib                0x3acd1715 realizeClass(objc_class*) + 220
2  libobjc.A.dylib                0x3acd1715 realizeClass(objc_class*) + 220
3  libobjc.A.dylib                0x3acd39ab lookUpImpOrForward + 74
4  libobjc.A.dylib                0x3acd3957 _class_lookupMethodAndLoadCache3 + 34
5  libobjc.A.dylib                0x3acd88b9 _objc_msgSend_uncached + 24
6  itsmysecond-ios                0x001287c7 -[Second getNextSecond:] (Second.m:93)
7  itsmysecond-ios                0x000fd5ff -[EBParallaxViewController adjustViewsToSeconds] (EBParallaxViewController.m:181)
8  itsmysecond-ios                0x000fd21d -[EBParallaxViewController scrollViewDidEndDecelerating:] (EBParallaxViewController.m:154)
9  UIKit                          0x32ed6957 -[UIScrollView(UIScrollViewInternal) _stopScrollDecelerationNotify:] + 806
10 UIKit                          0x32e0cd47 -[UIScrollView(UIScrollViewInternal) _stopScrollingNotify:pin:tramplingDragFlags:] + 466
11 UIKit                          0x32e0cb6b -[UIScrollView(UIScrollViewInternal) _stopScrollingNotify:pin:] + 30
12 UIKit                          0x32ed621b -[UIScrollView _smoothScrollWithUpdateTime:] + 3322
13 QuartzCore                     0x32a06df3 CA::Display::DisplayLinkItem::dispatch() + 98
14 QuartzCore                     0x32a06b9d CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 344
15 IOMobileFramebuffer            0x3577f75d IOMobileFramebufferVsyncNotifyFunc + 104
16 IOKit                          0x31209451 IODispatchCalloutFromCFMessage + 248
17 CoreFoundation                 0x304ddea9 __CFMachPortPerform + 136
18 CoreFoundation                 0x304e8a67 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 34
19 CoreFoundation                 0x304e8a03 __CFRunLoopDoSource1 + 346
20 CoreFoundation                 0x304e71d7 __CFRunLoopRun + 1398
21 CoreFoundation                 0x30451ebf CFRunLoopRunSpecific + 522
22 CoreFoundation                 0x30451ca3 CFRunLoopRunInMode + 106
23 GraphicsServices               0x35357663 GSEventRunModal + 138
24 UIKit                          0x32d9e14d UIApplicationMain + 1136
25 itsmysecond-ios                0x00109707 main (main.m:14)
26 libdyld.dylib                  0x3b1dbab7 start + 2

      

+3


source to share





All Articles