Orkhan Alizade Orkhan Alizade - 7 months ago 37
Swift Question

No visible @interface for 'JSQSystemSoundPlayer' error

I just added the files:

JSQSystemSoundPlayer.h
JSQSystemSoundPlayer.m


into my project and it rose the next error:

No visible @interface for 'JSQSystemSoundPlayer' declares the selector 'playAlertSoundWithFilename:fileExtension:'


I searched a lot but could'n find the solution. Can anyone know how to solve it?

Answer

This is the declaration of the method

- (void)playAlertSoundWithFilename:(NSString *)filename
                 fileExtension:(NSString *)fileExtension
                    completion:(nullable JSQSystemSoundPlayerCompletionBlock)completionBlock;

You're missing completion block, there is no such method with only two parameters

Here is example how to use it

[[JSQSystemSoundPlayer sharedPlayer] playSoundWithFilename:@"mySoundFile"
                                             fileExtension:kJSQSystemSoundTypeAIF
                                                completion:^{
                                                  // completion block code
                                                }];

Edit: As per comments

If you look at the declaration of playSoundWithFilename: fileExtension: completion: method you will find

@param completionBlock A block called after the sound has stopped playing.

Which means do whatever you want to do after the sound has stopped playing. If you don't want to do anything then either you can pass nil or empty block as above