有没有人设法使用NSUserNotification soundName来处理自定义声音?我试过aif和caf格式44100KHz 16bit 2秒的持续时间.通知会在适当的时间显示,并带有正确的标题和文字,但会播放默认声音而不是我的自定义声音.
声音文件已在应用程序包中正确复制.如果我试试这个声音可以正常工作:
NSSound* sound = [NSSound soundNamed:@"morse.aif"];
[sound play];
Run Code Online (Sandbox Code Playgroud)
但是当我在通知中使用相同的声音时,会播放默认通知声音:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
NSUserNotification* notification = [[NSUserNotification alloc]init];
notification.title = @"Titolo";
notification.deliveryDate = [NSDate dateWithTimeIntervalSinceNow:10];
notification.soundName = @"morse.aif";
[[NSUserNotificationCenter defaultUserNotificationCenter]scheduleNotification:notification];
}
Run Code Online (Sandbox Code Playgroud)
我尝试了无延伸,但没有成功.
notification.soundName = @"morse.aif";
notification.soundName = @"morse2.caf";
notification.soundName = @"morse";
Run Code Online (Sandbox Code Playgroud)
这些都不起作用.
我的应用程序没有签名,也没有沙盒,但我不认为这对用户通知是必要的,除了声音问题,通知工作得很好.
当我在Xcode 7.3.1(使用标准Swift 2编译器)中运行我的Swift应用程序并在断点处执行暂停时,我无法使用po
命令检查变量.我第一次运行po exists
(exists
在当前范围内是一个非可选的Bool变量)我得到一个很长的错误消息(见下文).从第二次开始运行相同的命令,我收到error loading helper function: (null)
消息.
应用程序在调试方案上编译和运行,没有"部署后处理"和无[-O0]优化.
变量内容在Xcode的变量检查器面板中正确显示.
po self
在设备和iOS模拟器上运行相同的错误或任何其他变量.
如果我运行一个新的干净项目,调试po
正常工作.
在目前的范围内:
var exists: Bool = self.canRemoveAttachmentForEpisode(episode)
NSLog("Exists is now \(exists)") // Breakpoint is set here
Run Code Online (Sandbox Code Playgroud)
这是调试器面板中发生的情况:
po exists
error loading helper function: <EXPR>:141:9: warning: '--' is deprecated: it will be removed in Swift 3
--maxItemCounter
^~
-= 1
<EXPR>:237:14: warning: '++' is deprecated: it will be removed in Swift 3
i++
^~
+= 1
<EXPR>:267:19: warning: …
Run Code Online (Sandbox Code Playgroud)