From c8ff56af65c7957e01a8c71e1dafabeee9b436c4 Mon Sep 17 00:00:00 2001 From: Guillermo Ignacio Enriquez Gutierrez Date: Mon, 13 Dec 2021 01:02:35 +0900 Subject: [PATCH] (ios) Fix warning in CDVNotification.m: Cast to smaller integer type 'int' from 'void *' --- src/ios/CDVNotification.m | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ios/CDVNotification.m b/src/ios/CDVNotification.m index bea6466b..dcced5a0 100644 --- a/src/ios/CDVNotification.m +++ b/src/ios/CDVNotification.m @@ -121,18 +121,25 @@ - (void)prompt:(CDVInvokedUrlCommand*)command static void playBeep(int count) { SystemSoundID completeSound; NSInteger cbDataCount = count; + NSNumber *cbDataCountNumber = @(cbDataCount-1); NSURL* audioPath = [[NSBundle mainBundle] URLForResource:@"CDVNotification.bundle/beep" withExtension:@"wav"]; #if __has_feature(objc_arc) AudioServicesCreateSystemSoundID((__bridge CFURLRef)audioPath, &completeSound); + AudioServicesAddSystemSoundCompletion(completeSound, NULL, NULL, soundCompletionCallback, (__bridge_retained void*) cbDataCountNumber); #else AudioServicesCreateSystemSoundID((CFURLRef)audioPath, &completeSound); + AudioServicesAddSystemSoundCompletion(completeSound, NULL, NULL, soundCompletionCallback, (void*)([cbDataCountNumber retain])); #endif - AudioServicesAddSystemSoundCompletion(completeSound, NULL, NULL, soundCompletionCallback, (void*)(cbDataCount-1)); AudioServicesPlaySystemSound(completeSound); } static void soundCompletionCallback(SystemSoundID ssid, void* data) { - int count = (int)data; + #if __has_feature(objc_arc) + NSNumber *cbDataCountNumber = (__bridge_transfer NSNumber *)data; + #else + NSNumber *cbDataCountNumber = [(NSNumber *)data release]; + #endif + int count = [cbDataCountNumber intValue]; AudioServicesRemoveSystemSoundCompletion (ssid); AudioServicesDisposeSystemSoundID(ssid); if (count > 0) {