Error when trying to play audio in iPhone app - ios

I am following udacity's course to try to learn how to make an iPhone app using xcode and swift. I am up to the part where I am playing an audio file when clicking a button in the app. Every time I click it, I get this error message:
in recordAudio
2015-04-05 14:42:18.124 Pitch Perfect[18544:1141273] -[Pitch_Perfect.PlaySoundsViewController slowAudio:]: unrecognized selector sent to instance 0x7f8174001760
2015-04-05 14:42:18.135 Pitch Perfect[18544:1141273] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Pitch_Perfect.PlaySoundsViewController slowAudio:]: unrecognized selector sent to instance 0x7f8174001760'
*** First throw call stack:
(
0 CoreFoundation 0x000000010ab57a75 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010c6afbb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010ab5ed1d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010aab69dc ___forwarding___ + 988
4 CoreFoundation 0x000000010aab6578 _CF_forwarding_prep_0 + 120
5 UIKit 0x000000010b3eba22 -[UIApplication sendAction:to:from:forEvent:] + 75
6 UIKit 0x000000010b4f2e50 -[UIControl _sendActionsForEvents:withEvent:] + 467
7 UIKit 0x000000010b4f221f -[UIControl touchesEnded:withEvent:] + 522
8 UIKit 0x000000010b431b68 -[UIWindow _sendTouchesForEvent:] + 735
9 UIKit 0x000000010b432493 -[UIWindow sendEvent:] + 683
10 UIKit 0x000000010b3fefb1 -[UIApplication sendEvent:] + 246
11 UIKit 0x000000010b40c227 _UIApplicationHandleEventFromQueueEvent + 17700
12 UIKit 0x000000010b3e723c _UIApplicationHandleEventQueue + 2066
13 CoreFoundation 0x000000010aa8cc91 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
14 CoreFoundation 0x000000010aa82b5d __CFRunLoopDoSources0 + 269
15 CoreFoundation 0x000000010aa82194 __CFRunLoopRun + 868
16 CoreFoundation 0x000000010aa81bc6 CFRunLoopRunSpecific + 470
17 GraphicsServices 0x000000010eb2da58 GSEventRunModal + 161
18 UIKit 0x000000010b3ea580 UIApplicationMain + 1282
19 Pitch Perfect 0x000000010a61d42e top_level_code + 78
20 Pitch Perfect 0x000000010a61d46a main + 42
21 libdyld.dylib 0x000000010ce8b145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
here is the code I have to play the audio. I can't seem to figure out what is wrong. I have been following all of the steps exactly.
// PlaySoundsViewController.swift
// Pitch Perfect
import UIKit
import AVFoundation
class PlaySoundsViewController: UIViewController {
var audioPlayer:AVAudioPlayer!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
if var filePath = NSBundle.mainBundle().pathForResource("movie_quote",ofType: "mp3"){
var filePathUrl = NSURL.fileURLWithPath(filePath)
audioPlayer = AVAudioPlayer(contentsOfURL: filePathUrl, error: nil)
} else{
println("the filepath is empty")
}
}
#IBAction func playSlowAudio(sender: UIButton) {
// Play audio slowly
audioPlayer.play()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
Can someone please help me find the issue? I am very new to app development.

It seems you have a method called slowAudio: somewhere, but haven't implemented that method in your controller; maybe connected to a button in IB? Right-click on the button in the storyboard (or xib) to bring up the black window to see if there's a connection there to a method called slowAudio:. If there is, delete the connection by clicking on the little "x".

Related

creating button that plays sound, getting NSException error

import UIKit
import AVFoundation
import AudioToolbox
class ViewController: UIViewController {
var player : AVAudioPlayer?
func playSound(){
let path = Bundle.main.path(forResource: "Roblox", ofType:"mp3")!
let url = URL(fileURLWithPath: path)
do {
let sound = try AVAudioPlayer(contentsOf: url)
self.player = sound
sound.numberOfLoops = 1
sound.prepareToPlay()
sound.play()
} catch {
print("error loading file")
// couldn't load file :(
}
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
#IBAction func button(_ sender: Any) {
playSound()
}
}
Hello, I am trying to make a button that plays a sound (Roblox.mp3). It compiles without errors. However, when I open the simulator, it crashes. My error log is:
2017-08-10 20:52:57.876 Oof[2500:252563] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<Oof.ViewController 0x7fc320607800> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key button.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010dcd6b0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010aa8a141 objc_exception_throw + 48
2 CoreFoundation 0x000000010dcd6a59 -[NSException raise] + 9
3 Foundation 0x000000010a5a000b -[NSObject(NSKeyValueCoding) setValue:forKey:] + 292
4 UIKit 0x000000010b0f7994 -[UIViewController setValue:forKey:] + 87
5 UIKit 0x000000010b364a09 -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x000000010dc7ce8d -[NSArray makeObjectsPerformSelector:] + 269
7 UIKit 0x000000010b3633bf -[UINib instantiateWithOwner:options:] + 1856
8 UIKit 0x000000010b0fdfc3 -[UIViewController _loadViewFromNibNamed:bundle:] + 381
9 UIKit 0x000000010b0fe8d9 -[UIViewController loadView] + 177
10 UIKit 0x000000010b0fec0a -[UIViewController loadViewIfRequired] + 195
11 UIKit 0x000000010b0ff45a -[UIViewController view] + 27
12 UIKit 0x000000010afc798a -[UIWindow addRootViewControllerViewIfPossible] + 65
13 UIKit 0x000000010afc8070 -[UIWindow _setHidden:forced:] + 294
14 UIKit 0x000000010afdaebe -[UIWindow makeKeyAndVisible] + 42
15 UIKit 0x000000010af5437f -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4346
16 UIKit 0x000000010af5a5e4 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1709
17 UIKit 0x000000010af577f3 -[UIApplication workspaceDidEndTransaction:] + 182
18 FrontBoardServices 0x00000001111765f6 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
19 FrontBoardServices 0x000000011117646d -[FBSSerialQueue _performNext] + 186
20 FrontBoardServices 0x00000001111767f6 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
21 CoreFoundation 0x000000010dc7cc01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
27 Oof 0x000000010a1429b7 main + 55
28 libdyld.dylib 0x0000000110b2d65d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
I am really not sure what is going wrong. I believe the sound I want is imported into Xcode because I drag and dropped it into my project. If the error is with the line that requests the sound, I may not have formatted it properly. I have seen it as both #"mp3" and typeOf("mp3"). Again, sorry if this seems rudimentary. I am just beginning with swift, and there are some...langauge barriers that I am struggling with.
Open your storyboard and goto Connection inspector you can see something like below screenshot.
#IBOutlet connection is binded but unknown to storyboard. this might be one reason of crashing your application.

Xcode 8.2.1 trying to make app keep getting output errors

I am probably trying to make the easiest app ever but I am unable to get it to work. The the app has two buttons. One that plays a short noise and the other is a donate button. I can get the noise to work but not the link or viceversa or neither. And one of the overrides keeps becoming an error and I dont know why so I put it as a comment so that the app would build. the error that comes up is that it asks me to remove the word override. Here is the code:
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&currency_code=CAD&bn=PP-DonationsBF%3Abtn_donateCC_LG.gif%3ANonHosted") {
UIApplication.shared.open(url, options: [:]) {
boolean in
// do something with the boolean
}
}
}
}
Here is the output information( might be an error for all i know, i dont know how to understand it):
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)
When exactly the app stops working?
Does it happen when you interact with an UI element, like one of the buttons?
I'm assuming there is a "Donate" button on the UI... Make sure that the connection from the button to the action is correctly wired.
One of the easiest ways to double-check the wiring is from the interface builder itself.
Click on the Connections Inspector button:
Search for any ! sign. If there are any, delete the connection and re-create it.
If the above doesn't do the trick, please share your project so I can help on debugging it.
(Regarding the didReceiveMemoryWarning override, you can safely delete it for now.)

Swift button error on iOS app but not in playground

I am trying to learn swift to make free educational app for my country.
I know only the basics of programming and swift, but I am trying to understand iOS development.
I think I am having a problem with scope, but not sure what to do.
With didMoveToView being (the required) according to books I read, I can't compile and execute the code. So, when I run it in Xcode iOS App Project, my App crashes (even though it works in playground).
The code:
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
class fooo {
static var bar = "hello world!"
#IBAction func hello_button(sender: AnyObject) {
print(fooo.bar)
}
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Below is the Crash log (Occurs on button touch):
2016-08-26 07:22:00.512 k[2074:37791] -[k.ViewController hello_button:]: unrecognized selector sent to instance 0x7aa2e670
2016-08-26 07:22:00.521 k[2074:37791] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[k.ViewController hello_button:]: unrecognized selector sent to instance 0x7aa2e670'
*** First throw call stack:
(
0 CoreFoundation 0x00200494 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01f17e02 objc_exception_throw + 50
2 CoreFoundation 0x0020a253 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0013f89d ___forwarding___ + 1037
4 CoreFoundation 0x0013f46e _CF_forwarding_prep_0 + 14
5 libobjc.A.dylib 0x01f2c0b5 -[NSObject performSelector:withObject:withObject:] + 84
6 UIKit 0x009f2e38 -[UIApplication sendAction:to:from:forEvent:] + 118
7 UIKit 0x009f2db7 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
8 UIKit 0x00b96f3b -[UIControl sendAction:to:forEvent:] + 79
9 UIKit 0x00b972d4 -[UIControl _sendActionsForEvents:withEvent:] + 433
10 UIKit 0x00b962c1 -[UIControl touchesEnded:withEvent:] + 714
11 UIKit 0x00a7352e -[UIWindow _sendTouchesForEvent:] + 1095
12 UIKit 0x00a745cc -[UIWindow sendEvent:] + 1159
13 UIKit 0x00a15be8 -[UIApplication sendEvent:] + 266
14 UIKit 0x009ea769 _UIApplicationHandleEventQueue + 7795
15 CoreFoundation 0x00112e5f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
16 CoreFoundation 0x00108aeb __CFRunLoopDoSources0 + 523
17 CoreFoundation 0x00107f08 __CFRunLoopRun + 1032
18 CoreFoundation 0x00107846 CFRunLoopRunSpecific + 470
19 CoreFoundation 0x0010765b CFRunLoopRunInMode + 123
20 GraphicsServices 0x04717664 GSEventRunModal + 192
21 GraphicsServices 0x047174a1 GSEventRun + 104
22 UIKit 0x009f0eb9 UIApplicationMain + 160
23 k 0x00012581 main + 145
24 libdyld.dylib 0x02935a25 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
You're right, the issue is scope (assuming you connected your button properly as others mentioned):
import UIKit
class ViewController: UIViewController {
class fooo {
var bar = "hello world!"
func mSayBar() { print(self.bar)}
}
var foo = fooo()
#IBAction func hello_button(sender: AnyObject) {
foo.mSayBar()
}
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
viewDidLoad is it's own local scope--it doesn't extend any further than the end brace " } "
After the first (millisecond?) everything declared in VDL is no longer alive; thus, it is best for initializing or calling, not declaring.
To declare global, just put everything in a new swift file, or put it outside ALL class scopes. Swift makes global scope easy (but be careful)
You said viewDidLoad is required, which is true, but only for setting up the program. Most of your logic / functions go outside of viewDidLoad
unrecognized selector sent to instance 0x7aa2e670 means that the button has been linked to an IBAction outlet that isn't defined in your code. Go to your ViewController's Storyboard mode, and right click the button in the subview list. Check if there is an outlet for the Touch Up Inside event and if it has the same name as the function in your code that you want to call (in your case it's hello_button.
Here's a picture if you didn't understand the above paragraph.

app crashing when trying to set a NSUserDefault with button

I'm creating an app and trying to update a NSUserDefault from a a different view controller, although i don't think its the separate view controller thats doing it because i can't set a new NSUserDefault on this controller either. its crashing whenever i push the button, heres the code from the view controller:
// Upgrades.swift
// Unit3Final
//
// Created by fgstu on 4/14/16.
// Copyright © 2016 AllenH. All rights reserved.
//
import UIKit
class Upgrades: UIViewController {
var tapModifier = (NSUserDefaults.standardUserDefaults().integerForKey("tapModifier"))
func storeTheScore() {
NSUserDefaults.standardUserDefaults().setInteger(tapModifier, forKey: "tapModifier")
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
#IBAction func BuyAHut(sender: UIButton) {
tapModifier += 5
storeTheScore()
}
}
it is set in my main view controller in my viewDidLoad with
var tapModifier: Int = 1
NSUserDefaults.standardUserDefaults().setInteger(tapModifier, forKey: "tapModifier")
and the error message is
2016-04-14 12:13:45.264 Unit3Final[40985:5120078] -[Unit3Final.Upgrades hutUpgrade:]: unrecognized selector sent to instance 0x7fadab4b2e80
2016-04-14 12:13:45.270 Unit3Final[40985:5120078] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Unit3Final.Upgrades hutUpgrade:]: unrecognized selector sent to instance 0x7fadab4b2e80'
*** First throw call stack:
(
0 CoreFoundation 0x000000010258de65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001042cddeb objc_exception_throw + 48
2 CoreFoundation 0x000000010259648d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00000001024e390a ___forwarding___ + 970
4 CoreFoundation 0x00000001024e34b8 _CF_forwarding_prep_0 + 120
5 UIKit 0x0000000102dac194 -[UIApplication sendAction:to:from:forEvent:] + 92
6 UIKit 0x0000000102f1b6fc -[UIControl sendAction:to:forEvent:] + 67
7 UIKit 0x0000000102f1b9c8 -[UIControl _sendActionsForEvents:withEvent:] + 311
8 UIKit 0x0000000102f1aaf8 -[UIControl touchesEnded:withEvent:] + 601
9 UIKit 0x0000000102e1b49b -[UIWindow _sendTouchesForEvent:] + 835
10 UIKit 0x0000000102e1c1d0 -[UIWindow sendEvent:] + 865
11 UIKit 0x0000000102dcab66 -[UIApplication sendEvent:] + 263
12 UIKit 0x0000000102da4d97 _UIApplicationHandleEventQueue + 6844
13 CoreFoundation 0x00000001024b9a31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
14 CoreFoundation 0x00000001024af95c __CFRunLoopDoSources0 + 556
15 CoreFoundation 0x00000001024aee13 __CFRunLoopRun + 867
16 CoreFoundation 0x00000001024ae828 CFRunLoopRunSpecific + 488
17 GraphicsServices 0x0000000106bcdad2 GSEventRunModal + 161
18 UIKit 0x0000000102daa610 UIApplicationMain + 171
19 Unit3Final 0x000000010201db7d main + 109
20 libdyld.dylib 0x0000000104ddf92d start + 1
21 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
It doesn't have a value, that's why it's crashing, try setting it to 0 initially.
You're adding 5 to nothing, instead of this,
tapModifier = NSUserDefaults etc...
try...
tapModifier = 0

Several errors when running my first iOS app

I'm able to run the app initially (no visible errors), but when I input a number in the ageBox area and press the getAge button, I get several errors.
Here is the code:
import UIKit
class ViewController: UIViewController {
#IBOutlet var ageBox: UITextField!
#IBAction func getAge(sender: AnyObject) {
println(ageBox.text)
}
#IBOutlet var answerLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Here is the error I get:
2015-04-21 10:36:24.183 Cat Years[5284:2484424] Can't find keyplane
that supports type 4 for keyboard iPhone-PortraitChoco-NumberPad;
using 2705787216_PortraitChoco_iPhone-Simple-Pad_Default
2015-04-21 10:36:25.826 Cat Years[5284:2484424] Can't find keyplane
that supports type 4 for keyboard iPhone-PortraitChoco-NumberPad;
using 2705787216_PortraitChoco_iPhone-Simple-Pad_Default
5
2015-04-21 10:36:27.067 Cat Years[5284:2484424]
-[Cat_Years.ViewController getAgeButton:]: unrecognized selector sent to instance 0x7fc881e287f0
2015-04-21 10:36:27.078 Cat Years[5284:2484424] *** Terminating app
due to uncaught exception 'NSInvalidArgumentException', reason:
'-[Cat_Years.ViewController getAgeButton:]: unrecognized selector sent
to instance 0x7fc881e287f0'
*** First throw call stack:
(
0 CoreFoundation 0x00000001044c5c65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000106030bb7 objc_exception_throw + 45
2 CoreFoundation 0x00000001044cd0ad -[NSObject(NSObject)
doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010442313c forwarding + 988
4 CoreFoundation 0x0000000104422cd8 _CF_forwarding_prep_0 + 120
5 UIKit 0x0000000104d65da2 -[UIApplication
sendAction:to:from:forEvent:] + 75
6 UIKit 0x0000000104e7754a -[UIControl
_sendActionsForEvents:withEvent:] + 467
7 UIKit 0x0000000104e76919 -[UIControl touchesEnded:withEvent:] + 522
8 UIKit 0x0000000104db2998 -[UIWindow _sendTouchesForEvent:] + 735
9 UIKit 0x0000000104db32c2 -[UIWindow sendEvent:] + 682
10 UIKit 0x0000000104d79581 -[UIApplication sendEvent:] + 246
11 UIKit 0x0000000104d86d1c _UIApplicationHandleEventFromQueueEvent +
18265
12 UIKit 0x0000000104d615dc _UIApplicationHandleEventQueue + 2066
13 CoreFoundation 0x00000001043f9431
CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
14 CoreFoundation 0x00000001043ef2fd __CFRunLoopDoSources0 + 269
15 CoreFoundation 0x00000001043ee934 __CFRunLoopRun + 868
16 CoreFoundation 0x00000001043ee366 CFRunLoopRunSpecific + 470
17 GraphicsServices 0x00000001084aca3e GSEventRunModal + 161
18 UIKit 0x0000000104d64900 UIApplicationMain + 1282
19 Cat Years 0x00000001042c8007 main + 135
20 libdyld.dylib 0x0000000106788145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type
NSException
Any ideas?
Copied your code to a new project. Added a text box, switch, and label. Did the connections. Added constraints using "Add Missing Constraints". And it all worked (with no modification to your view controller code). Here is the link:
Project
The possibilities I can think of (based on errors I made when I started): (1) in changing connections while editing the storyboard I found that deleted controls are not automatically deleted in the xml file. Suggest you look in the connections editor to see if there are controls that you deleted. (2) do a "clean" to make sure.
Good luck
For the keyplane error,try this:
For reference:see this
iOS Simulator -> Hardware -> Keyboard -> Connect Hardware Keyboard
so that the entry is UNchecked then the software keyboard will be displayed once again.
For the NSInvalidArgumentException',try this:
#IBAction func getAge(sender: UIButton) {
println(ageBox.text)
}

Resources