Reputation: 12351
I'm trying to pass a UILabel
with AudioServicesAddSystemSoundCompletion
but i'm not able to manipulate the value within the completionCallback
method. I'm using ARC and Xcode suggested adding (_bridge void*)
.
Any help would be much appreciated.
-(void) playWordSound:(UILabel *)label
{
NSString *path;
SystemSoundID soundId;
switch (label.tag)
{
case 1:
..........
break;
}
NSURL *url = [NSURL fileURLWithPath:path];
AudioServicesCreateSystemSoundID( (CFURLRef)objc_unretainedPointer( url), &soundId);
AudioServicesPlaySystemSound(soundId);
AudioServicesAddSystemSoundCompletion (soundId, NULL, NULL,
completionCallback,
(__bridge void*) label);
}
static void completionCallback (SystemSoundID mySSID, void* data) {
NSLog(@"completion Callback");
AudioServicesRemoveSystemSoundCompletion (mySSID);
//the below line is not working
//label.textColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1];
}
Upvotes: 1
Views: 884
Reputation: 57179
In the completion handler the label is stored in data
. You need to __bridge
it back to use it.
static void completionCallback (SystemSoundID mySSID, void* data) {
NSLog(@"completion Callback");
AudioServicesRemoveSystemSoundCompletion (mySSID);
UILabel *label = (__bridge UILabel*)data;
label.textColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1];
}
Upvotes: 3