Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nacho4d
Copy link

@nacho4d nacho4d commented Dec 12, 2021

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

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • 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)
  • I've updated the documentation if necessary

@nacho4d nacho4d changed the title Fix warning in CDVNotification.m: Cast to smaller integer type 'int' from 'void *' (ios) Fix warning in CDVNotification.m: Cast to smaller integer type 'int' from 'void *' Dec 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant