Xcode 8.2.1 试图让应用不断收到输出错误
Xcode 8.2.1 trying to make app keep getting output errors
我可能正在尝试制作有史以来最简单的应用程序,但我无法让它工作。该应用程序有两个按钮。一个播放短促的声音,另一个是捐赠按钮。我可以让噪音工作但 link 或反之亦然或两者都不是。其中一个覆盖不断成为一个错误,我不知道为什么,所以我把它作为评论,以便应用程序能够构建。出现的错误是它要求我删除覆盖一词。这是代码:
import UIKit
import AVFoundation
class ViewController: UIViewController {
let soundFilenames = ["WeahV2"]
var audioPlayers = [AVAudioPlayer]()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
// Set up audio player
for sound in soundFilenames {
do {
// Try to do something
let url = NSURL(fileURLWithPath: Bundle.main.path( forResource: sound, ofType: "mp3")!)
let audioPlayer = try AVAudioPlayer(contentsOf: url as URL)
audioPlayers.append(audioPlayer)
}
catch {
//catch the error that is thrown
audioPlayers.append(AVAudioPlayer())
}
}
}
//override func didReceiveMemoryWarning() {
// super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
//}
@IBAction func buttonTapped(_ sender: UIButton) {
// get the audio player that corresponds with the button tapped
let audioPlayer = audioPlayers[sender.tag]
audioPlayer.play()
}
@IBAction func Donate( sender: AnyObject) {
if let url = URL(string: "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=5Q29GRLXF4W9C&lc=CA&item_name=BiBoCo¤cy_code=CAD&bn=PP-DonationsBF%3Abtn_donateCC_LG.gif%3ANonHosted") {
UIApplication.shared.open(url, options: [:]) {
boolean in
// do something with the boolean
}
}
}
}
这是输出信息(可能是我所知道的错误,我不知道如何理解它):
2017-03-08 17:10:34.256692 The Weah[22117:1032077] [aqme] 255: AQDefaultDevice (1): skipping input stream 0 0 0x0
2017-03-08 17:10:36.241162 The Weah[22117:1032029] [aqme] 177: timed out after 0.012s (126 127); suspension count=0 (IOSuspensions: )
2017-03-08 17:10:36.264895 The Weah[22117:1032077] [aqme] 255: AQDefaultDevice (128): skipping input stream 0 0 0x0
2017-03-08 17:10:36.498 The Weah[22117:1030634] -[The_Weah.ViewController Donate:]: unrecognized selector sent to instance 0x7fef9a806b20
2017-03-08 17:10:37.037 The Weah[22117:1030634] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[The_Weah.ViewController Donate:]: unrecognized selector sent to instance 0x7fef9a806b20'
*** First throw call stack:
(
0 CoreFoundation 0x000000010ca9dd4b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010c4ff21e objc_exception_throw + 48
2 CoreFoundation 0x000000010cb0df04 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x000000010ca23005 ___forwarding___ + 1013
4 CoreFoundation 0x000000010ca22b88 _CF_forwarding_prep_0 + 120
5 UIKit 0x000000010cec38bc -[UIApplication sendAction:to:from:forEvent:] + 83
6 UIKit 0x000000010d049c38 -[UIControl sendAction:to:forEvent:] + 67
7 UIKit 0x000000010d049f51 -[UIControl _sendActionsForEvents:withEvent:] + 444
8 UIKit 0x000000010d048e4d -[UIControl touchesEnded:withEvent:] + 668
9 UIKit 0x000000010cf31545 -[UIWindow _sendTouchesForEvent:] + 2747
10 UIKit 0x000000010cf32c33 -[UIWindow sendEvent:] + 4011
11 UIKit 0x000000010cedf9ab -[UIApplication sendEvent:] + 371
12 UIKit 0x000000010d6cc72d __dispatchPreprocessedEventFromEventQueue + 3248
13 UIKit 0x000000010d6c5463 __handleEventQueue + 4879
14 CoreFoundation 0x000000010ca42761 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
15 CoreFoundation 0x000000010ca2798c __CFRunLoopDoSources0 + 556
16 CoreFoundation 0x000000010ca26e76 __CFRunLoopRun + 918
17 CoreFoundation 0x000000010ca26884 CFRunLoopRunSpecific + 420
18 GraphicsServices 0x00000001116eda6f GSEventRunModal + 161
19 UIKit 0x000000010cec1c68 UIApplicationMain + 159
20 The Weah 0x000000010bbb56bf main + 111
21 libdyld.dylib 0x0000000111ce168d start + 1
22 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
应用程序停止运行的确切时间?
当您与 UI 元素(例如其中一个按钮)交互时会发生这种情况吗?
我假设 UI 上有一个 "Donate" 按钮...确保从按钮到操作的连接正确连接。
仔细检查接线的最简单方法之一是从界面生成器本身。
单击 Connections Inspector 按钮:
搜索任何 !
标志。如果有,删除连接重新创建。
如果上述方法不起作用,请分享您的项目,以便我帮助调试它。
(关于 didReceiveMemoryWarning
覆盖,您现在可以安全地删除它。)
我可能正在尝试制作有史以来最简单的应用程序,但我无法让它工作。该应用程序有两个按钮。一个播放短促的声音,另一个是捐赠按钮。我可以让噪音工作但 link 或反之亦然或两者都不是。其中一个覆盖不断成为一个错误,我不知道为什么,所以我把它作为评论,以便应用程序能够构建。出现的错误是它要求我删除覆盖一词。这是代码:
import UIKit
import AVFoundation
class ViewController: UIViewController {
let soundFilenames = ["WeahV2"]
var audioPlayers = [AVAudioPlayer]()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
// Set up audio player
for sound in soundFilenames {
do {
// Try to do something
let url = NSURL(fileURLWithPath: Bundle.main.path( forResource: sound, ofType: "mp3")!)
let audioPlayer = try AVAudioPlayer(contentsOf: url as URL)
audioPlayers.append(audioPlayer)
}
catch {
//catch the error that is thrown
audioPlayers.append(AVAudioPlayer())
}
}
}
//override func didReceiveMemoryWarning() {
// super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
//}
@IBAction func buttonTapped(_ sender: UIButton) {
// get the audio player that corresponds with the button tapped
let audioPlayer = audioPlayers[sender.tag]
audioPlayer.play()
}
@IBAction func Donate( sender: AnyObject) {
if let url = URL(string: "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=5Q29GRLXF4W9C&lc=CA&item_name=BiBoCo¤cy_code=CAD&bn=PP-DonationsBF%3Abtn_donateCC_LG.gif%3ANonHosted") {
UIApplication.shared.open(url, options: [:]) {
boolean in
// do something with the boolean
}
}
}
}
这是输出信息(可能是我所知道的错误,我不知道如何理解它):
2017-03-08 17:10:34.256692 The Weah[22117:1032077] [aqme] 255: AQDefaultDevice (1): skipping input stream 0 0 0x0 2017-03-08 17:10:36.241162 The Weah[22117:1032029] [aqme] 177: timed out after 0.012s (126 127); suspension count=0 (IOSuspensions: ) 2017-03-08 17:10:36.264895 The Weah[22117:1032077] [aqme] 255: AQDefaultDevice (128): skipping input stream 0 0 0x0 2017-03-08 17:10:36.498 The Weah[22117:1030634] -[The_Weah.ViewController Donate:]: unrecognized selector sent to instance 0x7fef9a806b20 2017-03-08 17:10:37.037 The Weah[22117:1030634] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[The_Weah.ViewController Donate:]: unrecognized selector sent to instance 0x7fef9a806b20' *** First throw call stack: ( 0 CoreFoundation 0x000000010ca9dd4b __exceptionPreprocess + 171 1 libobjc.A.dylib 0x000000010c4ff21e objc_exception_throw + 48 2 CoreFoundation 0x000000010cb0df04 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132 3 CoreFoundation 0x000000010ca23005 ___forwarding___ + 1013 4 CoreFoundation 0x000000010ca22b88 _CF_forwarding_prep_0 + 120 5 UIKit 0x000000010cec38bc -[UIApplication sendAction:to:from:forEvent:] + 83 6 UIKit 0x000000010d049c38 -[UIControl sendAction:to:forEvent:] + 67 7 UIKit 0x000000010d049f51 -[UIControl _sendActionsForEvents:withEvent:] + 444 8 UIKit 0x000000010d048e4d -[UIControl touchesEnded:withEvent:] + 668 9 UIKit 0x000000010cf31545 -[UIWindow _sendTouchesForEvent:] + 2747 10 UIKit 0x000000010cf32c33 -[UIWindow sendEvent:] + 4011 11 UIKit 0x000000010cedf9ab -[UIApplication sendEvent:] + 371 12 UIKit 0x000000010d6cc72d __dispatchPreprocessedEventFromEventQueue + 3248 13 UIKit 0x000000010d6c5463 __handleEventQueue + 4879 14 CoreFoundation 0x000000010ca42761 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 15 CoreFoundation 0x000000010ca2798c __CFRunLoopDoSources0 + 556 16 CoreFoundation 0x000000010ca26e76 __CFRunLoopRun + 918 17 CoreFoundation 0x000000010ca26884 CFRunLoopRunSpecific + 420 18 GraphicsServices 0x00000001116eda6f GSEventRunModal + 161 19 UIKit 0x000000010cec1c68 UIApplicationMain + 159 20 The Weah 0x000000010bbb56bf main + 111 21 libdyld.dylib 0x0000000111ce168d start + 1 22 ??? 0x0000000000000001 0x0 + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)
应用程序停止运行的确切时间?
当您与 UI 元素(例如其中一个按钮)交互时会发生这种情况吗?
我假设 UI 上有一个 "Donate" 按钮...确保从按钮到操作的连接正确连接。
仔细检查接线的最简单方法之一是从界面生成器本身。
单击 Connections Inspector 按钮:
搜索任何 !
标志。如果有,删除连接重新创建。
如果上述方法不起作用,请分享您的项目,以便我帮助调试它。
(关于 didReceiveMemoryWarning
覆盖,您现在可以安全地删除它。)