【发布时间】:2015-03-08 21:44:11
【问题描述】:
这是几行代码,几乎是从 GBA4iOS 控制器视图中逐字提取的,用于更改振动的长度:
void AudioServicesStopSystemSound(int);
void AudioServicesPlaySystemSoundWithVibration(int, id, NSDictionary *);
@implementation vibeObject;
- (void)vibrate
{
AudioServicesStopSystemSound(kSystemSoundID_Vibrate);
int64_t vibrationLength = 30;
NSArray *pattern = @[@NO, @0, @YES, @(vibrationLength)];
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
dictionary[@"VibePattern"] = pattern;
dictionary[@"Intensity"] = @1;
AudioServicesPlaySystemSoundWithVibration(kSystemSoundID_Vibrate, nil, dictionary);
}
@end
我在这里的尝试只是拒绝在任何情况下工作:
func AudioServicesStopSystemSound(Int);
func AudioServicesPlaySystemSoundWithVibration(Int , NilLiteralConvertible, NSDictionary)();
func vibrate(){
AudioServicesStopSystemSound(kSystemSoundID_Vibrate);
let vibrationLength = 30;
let pattern: NSArray = [false, 0, true, vibrationLength];
var dictionary:NSMutableDictionary;
dictionary["VibePattern"] = pattern;
dictionary["Intensity"] = 1;
AudioServicesPlaySystemSoundWithVibration(kSystemSoundID_Vibrate, nil, dictionary);
}
如果不加注释,它会使 SourceKit 崩溃,但仅在视图控制器中。当我把它放在自己的文件中时:
vibeObject.vibrate(<# RIGHT HERE IT TELLS ME "EXPECTED ',' SEPARATOR vibeObject#>);
我已经尽力了,如果你能提供帮助将不胜感激
【问题讨论】:
标签: ios objective-c swift uikit audiotoolbox