You should not store the address of the sound ID but the sound ID itself
in the property (i.e., remove the *
):
@property SystemSoundID theSound;
and then use it as
[self setTheSound:thisSoundID];
AudioServicesPlaySystemSound(self.theSound);
In your case, self.theSound
is the address of the local variable thisSoundID
.
As soon as you leave the function where this variable is declared, that memory
location might be reused for something else, and referring to it is "undefined
behaviour".
(Side note: for instance variables and properties, use names starting with a lowercase letter.)