Question

I know this questions has been posted a lot, but they are all very specific and do not apply to my problem.

[MirrorStarAV startRecording:]: unrecognized selector sent to instance 0x15561d60

I get this error when calling the following method:

- (bool) startRecording {
    bool result = NO;
    @synchronized(self) {
        if (!_recording) { //Exception is raised on this line
            result = [self setUpWriter];
            startedAt = [[NSDate date] retain];
            _recording = YES;
         }
    }

    return result;
}

I call the method as following:

bool _startRecording(){
    return [delegateMSA startRecording];
}
Was it helpful?

Solution

[MirrorStarAV startRecording:]: unrecognized selector sent to instance 0x15561d60

The above error message is basically saying that MirrorStarAV doesn't respond to startRecording: so when you call [delegateMSA startRecording]; it is crashing. The delegateMSA has an instance of MirrorStarAV set to it but instances of MirrorStarAV don't respond to `startRecording:

Whilst YES it would be better for you to change your method to something like

bool _startRecording(){
    if ([delegateMSA respondsToSelector:@selector(startRecording)])
    {
        return [delegateMSA startRecording];
    }
    return false;
}

but this isn't your issue. Note that [MirrorStarAV startRecording:] has a colon : at the end. You are calling startRecording: somewhere over startRecording

OTHER TIPS

Check before, whether the delegate responds to this method, so you can make sure that the object is also able to respond to this selector:

bool _startRecording(){
    if ([delegateMSA respondsToSelector:@selector(startRecording)])
    {
        return [delegateMSA startRecording];
    }
    return false;
}

Either way, I would recommend to add this selector to the delegates methods with @required:

@protocol MyRecorderDelegate <NSObject>

@required
- (BOOL)startRecording;

@end

So, you would get a compiler warning, if your delegate was not implementing this method.

Verify if the delegateMSA is an instance of class where you have the startRecording method.

Or do something like

bool _startRecording(){
   if([delegateMSA respondsToSelector:@selector(startRecording)]) {
       return [delegateMSA startRecording];
   }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top