cordova-plugin-dialogs icon indicating copy to clipboard operation
cordova-plugin-dialogs copied to clipboard

(ios) Fix warning in CDVNotification.m: Cast to smaller integer type 'int' from 'void *'

Open nacho4d opened this issue 3 years ago • 0 comments

Platforms affected

iOS

Motivation and Context

Xcode reports warning in CDVNotification.m in soundCompletionCallback (callback function of AudioServicesAddSystemSoundCompletion playBeep).

Screen Shot 2021-12-13 at 1 16 48

Description

  • In order to implement an loop counter an int was passed to the callback function (which requires void*) so internally a cast from void* to int was required. However, this is a fragile approach and recent versions of Xcode warns about this.

  • Instead of using a raw int value I changed to NSNumber which is is a pointer and can be retained while the beep is being played.

  • I wrote the code to support ARC and non-ARC code as same as surrounding code.

Testing

Play beep works normally. No visible changes for users as expected.

Checklist

  • [x] I've run the tests to see all new and existing tests pass
  • [x] I added automated test coverage as appropriate for this change
  • [x] Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • [x] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • [x] I've updated the documentation if necessary

nacho4d avatar Dec 12 '21 16:12 nacho4d