Thread 1: Signal SIGABRT caused from systemSound - ios

Hey I am very new to programming in x-code and I have been following geeky lemon's tutorial, and I wanted to add sound into my project. I am trying to create a simple piano application. I have followed every step correctly, and my code was exactly same as their although when I ran the program, the iphone simulator froze at black screen and opened xcode with
Thread 1: Signal SIGABRT in
int main(int argc, char *argv[])
{
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}T}
In the console the error was:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSURL initFileURLWithPath:]: nil string parameter'
* First throw call stack:
My code is:
.h
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
#interface ViewController : UIViewController
{
SystemSoundID soundID;
}
- (IBAction)c1Press:(id)sender;
#end
.m
#import "ViewController.h"
#interface ViewController ()
#end
#implementation ViewController
- (void)viewDidLoad
{
NSURL *buttonURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"Resource/Audio/keys/C1" ofType:#"MP3"]];
AudioServicesCreateSystemSoundID((__bridge CFURLRef) buttonURL, &soundID);
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)c1Press:(id)sender {
AudioServicesPlaySystemSound(soundID);
}
#end
I have done some research on this, and one answer was that the bundle was not in properly or something like that, but I checked in my build Phases and all my resources are all there and none are red.

Related

Trying to create a button in Xcode Objective-C

I am just trying something completely new and simple in Xcode. I was looking a tutorial to create a button that plays music or a sound. All seemed to be okay until preview time. There seems to be an expected identifier issue at IBAction as well as it expected something after (void). But each time I do as the prompt says the prompts multiply. I've tried to do as all of them said but then it was no longer the same function. Any ideas?
#import "ViewController.h"
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
#interface StrackerViewController : ViewController
//#end
//#implementation StrackerViewController: ViewController
- (IBAction) epic; {
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) # "epic", CFSTR ("mp3"),NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#end
Your IBAction is not a properly formed function. It needs to be in the form:
-(IBAction) epic:(id)sender {
Once you have done that you should probably delete and remake the link with your storyboard as that is likely to be broken too.

this class is not key value coding-compliant for the key setOutput [duplicate]

This question already has answers here:
Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X" error?
(79 answers)
Closed 8 years ago.
I am brand new to iOS/Objective-C and I am trying to learn. I am following along in Sam's Teach yourself iOS. I am doing a project called Hello Noun, where instead of displaying Hello World, it takes an input and displays "Hello Input".
Working on the project, everything was fine, and there were no errors. But when I went to Build and then Run the app, it crashed saying;
'NSUnknownKeyException', reason: '[<ViewController 0xa064620> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key setOutput.'
and pointed to main.m file highlighting these lines;
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[])
{
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
The rest of the code used is below;
ViewController.m
#interface ViewController ()
#property (weak, nonatomic) IBOutlet UILabel *userOutput;
#property (weak, nonatomic) IBOutlet UITextField *userInput;
- (IBAction)setOutput:(id)sender;
#end
#implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)setOutput:(id)sender {
self.userOutput.text=self.userInput.text;
}
#end
I am new to this, and I'm just getting my bearings so I'm not quite sure what is happening. Any help would be beyond appreciated.
Go to your ViewController xib/Storyboard right click on the File's Owner you should find a yellow alert icon there delete that connection , it should solve your problem.

this class is not key value coding-compliant for the key pdfView [duplicate]

This question already has answers here:
Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X" error?
(79 answers)
Closed 8 years ago.
I am making a somewhat basic ios application and i am trying to have the user click on a cell in a uitableview and then have it open a pdf. I am running into a strange error though. When i click on the cell the app crashes and this is my error
014-01-14 20:15:09.782 CCHA App[1171:60b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<PDFDetailViewController 0x15680a10> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key pdfView.'
*** First throw call stack:
(0x3000ef4b 0x3a44f6af 0x3000ec61 0x3094e18b 0x3095fdd5 0x2ff7ee6f 0x32ae0f87 0x32a42917 0x328a4389 0x327861bd 0x32786139 0x329123eb 0x32830273 0x3283007d 0x32830015 0x32781da3 0x32408c6b 0x3240447b 0x3240430d 0x32403d1f 0x32403b2f 0x323fd85d 0x2ffda1cd 0x2ffd7b71 0x2ffd7eb3 0x2ff42c27 0x2ff42a0b 0x34c69283 0x327e6049 0x18269 0x3a957ab7)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Here is some of my code!
//
// PDFDetailViewController.h
// CCHA App
//
// Created on 1/14/14.
// Copyright (c) 2014 CCHA. All rights reserved.
//
#import <UIKit/UIKit.h>
#interface PDFDetailViewController : UIViewController {
}
#property (strong, nonatomic) IBOutlet UIWebView *PDFWebView;
#end
//
// PDFDetailViewController.m
// CCHA App
//
// Created on 1/14/14.
// Copyright (c) 2014 CCHA. All rights reserved.
//
#import "PDFDetailViewController.h"
#interface PDFDetailViewController ()
#end
#implementation PDFDetailViewController
#synthesize PDFWebView;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
NSString *path = [[NSBundle mainBundle] pathForResource:#"TestingDoc" ofType:#"pdf"];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[PDFWebView loadRequest:request];
[PDFWebView setScalesPageToFit:YES];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#end
I cant figure out why this is happening and any help would be greatly appreciated. Thank you!!
This happens if you have created a IBOUTLET with name "pdfView" and later on you changed it "PDFWebView".
Look in to your interface builder.
Select Files owner.
Right Click on it.
There will be one outlet which will be showing a Alert sign.
The problem is probably in your storyboard (or .xib file). You set up an outlet there when the name was pdfView. Then you changed the name in the code to PDFWebView but you forgot to change the name of the outlet, so now you have a bad outlet and you are crashing when the nib loads and the name of the outlet no longer matches the name of the property.

How to implement sound into an existent app, without Cocos2D

For example, on the iOS SDK download page, there's sample code; I'm using the calculator app (iPhoneUnitTests). I would like to know if it is possible to add sounds to the button presses on the app that's already built, easily.
It is actually very simple to play short sounds, like button sounds. Here is a quick example.
You must link the AudioToolbox.framework binary
SoundExampleViewController.h;
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
#interface SoundExampleViewController : UIViewController{
SystemSoundID mySoundID;
}
#end
SoundExampleViewController.m:
#import "SoundExampleViewController.h"
#implementation SoundExampleViewController
- (void)viewDidLoad{
[super viewDidLoad];
NSString *path = [[NSBundle mainBundle] pathForResource:#"SoundFileName" ofType:#"wav"];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:path],&mySoundID);
}
- (void)viewDidUnload{
[super viewDidUnload];
AudioServicesDisposeSystemSoundID(mySoundID);
}
#end
Then to play you simply call: AudioServicesPlaySystemSound(mySoundID);

Error : Program received Signal : "SIGABRT" , How to Sovle this error in XCode 4.0.2?

I am new in iPhone technology, i am making one sample iPhone application in XCode 4.0.2 and getting error while i am executing my iPhone. I simply wants to show the text field value in a lable on Button Click event. but the application is showing error on this line
#import <UIKit/UIKit.h>
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
// Error Pointing on Above line as Thread 1 : Program received Signal : "SIGABRT"
[pool release];
return retVal;
}
as . I tried but error is not going ... Can Anyone help me !!!!
This is my code for : helloworldViewController.m
#import "helloworldViewController.h"
#implementation helloworldViewController
#synthesize Text;
#synthesize Label;
#synthesize goButton;
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
}
-(IBAction)Go: (id) sender
{
NSString *str = [[NSString alloc] initWithFormat:#"Hello, %#", Text.text];
//NSLog(#"%#",str);
//NSLog(#"Hey, M working on button click event !!! Finish");
[Text resignFirstResponder ];
//This Code is For Displaying the Enterred Textfield value into Label.
[Label setText:str];
}
#pragma mark - View lifecycle
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)viewDidUnload
{
[super viewDidUnload];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
- (void)dealloc
{
[super dealloc];
}
#end
And Below one is for : helloworldViewController.h
#import <UIKit/UIKit.h>
#interface helloworldViewController : UIViewController {
}
#property(nonatomic,retain) IBOutlet UITextField *Text;
#property(nonatomic,retain) IBOutlet UILabel *Label;
#property(nonatomic,retain) IBOutlet UIButton *goButton;
-(IBAction)Go: (id) sender;
#end
In Console Window i am getting Below one error :
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UICustomObject 0x4b31e00> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key navigationController.'
Regards,
Tauseef Khan
Your code is all ok. Instead of some Naming conventions ;) I recommend this doc http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingBasics.html#//apple_ref/doc/uid/20001281-BBCHBFAH
I think that you have set up a Connection in Interface Builder to the View Controller wich send this Message at wich the ViewController has no method for.

Resources