Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-22-2011, 05:38 PM   #1 (permalink)
Registered Member
 
Join Date: May 2011
Location: Berlin
Posts: 8
jojo is on a distinguished road
Exclamation terminate called after throwing an instance of 'NSException'

i have a button
---
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];

[button addTarget:self action:@selector(playSound) forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"Button x" forState:UIControlStateNormal];
button.frame = CGRectMake(100.0, 100.0, 120.0, 50.0);
[self.view addSubview:button];

-----
and
-----------
- (void)playSound
{

NSString *path = [[NSBundle mainBundle] pathForResource:@"Tink.caf" ofType:@"caf"];
AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPathath] error:nil];
newPlayer.delegate = self;
newPlayer.volume = 1;
[newPlayer play];
self.sound1Player = newPlayer;
[newPlayer release];


}

--

after pressing the button:

----
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
*** Call stack at first throw:
(
0 CoreFoundation 0x3537864f __exceptionPreprocess + 114
1 libobjc.A.dylib 0x36306c5d objc_exception_throw + 24
2 CoreFoundation 0x35378491 +[NSException raise:format:arguments:] + 68
3 CoreFoundation 0x353784cb +[NSException raise:format:] + 34
4 Foundation 0x312e718f -[NSURL(NSURL) initFileURLWithPath:] + 70
5 Foundation 0x312e712f +[NSURL(NSURL) fileURLWithPath:] + 30
6 IBODY 0x00004f63 -[IBODYViewController playSound] + 134
7 CoreFoundation 0x352e8571 -[NSObject(NSObject) performSelector:withObject:withObject:] + 24
8 UIKit 0x365fcec9 -[UIApplication sendAction:to:from:forEvent:] + 84
9 UIKit 0x365fce69 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 32
10 UIKit 0x365fce3b -[UIControl sendAction:to:forEvent:] + 38
11 UIKit 0x365fcb8d -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 356
12 UIKit 0x365fd423 -[UIControl touchesEnded:withEvent:] + 342
13 UIKit 0x365fbbf5 -[UIWindow _sendTouchesForEvent:] + 368
14 UIKit 0x365fb56f -[UIWindow sendEvent:] + 262
15 UIKit 0x365e4313 -[UIApplication sendEvent:] + 298
16 UIKit 0x365e3c53 _UIApplicationHandleEvent + 5090
17 GraphicsServices 0x35b52e77 PurpleEventCallback + 666
18 CoreFoundation 0x3534fa97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FU NCTION__ + 26
19 CoreFoundation 0x3535183f __CFRunLoopDoSource1 + 166
20 CoreFoundation 0x3535260d __CFRunLoopRun + 520
21 CoreFoundation 0x352e2ec3 CFRunLoopRunSpecific + 230
22 CoreFoundation 0x352e2dcb CFRunLoopRunInMode + 58
23 GraphicsServices 0x35b5241f GSEventRunModal + 114
24 GraphicsServices 0x35b524cb GSEventRun + 62
25 UIKit 0x3660ed69 -[UIApplication _run] + 404
26 UIKit 0x3660c807 UIApplicationMain + 670
27 IBODY 0x00002587 main + 82
28 IBODY 0x00002530 start + 40
)
terminate called after throwing an instance of 'NSException'
warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.4 (8K2)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib (file not found).
(gdb)

--

what is going on???
jojo is offline   Reply With Quote
Old 07-22-2011, 05:50 PM   #2 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

Quote:
[NSURL initFileURLWithPath:]: nil string parameter
Isn't it obvious?

My guess is the problem is the extra extension in the pathForResource call.
baja_yu is offline   Reply With Quote
Old 07-22-2011, 05:56 PM   #3 (permalink)
Registered Member
 
Join Date: May 2011
Location: Berlin
Posts: 8
jojo is on a distinguished road
Default

Quote:
Originally Posted by baja_yu View Post
Isn't it obvious?


NO otherwise i didn't ask

My guess is the problem is the extra extension in the pathForResource call.
what do you mean by the extra extension?

can you explain?

thanks JOJO
jojo is offline   Reply With Quote
Old 07-22-2011, 06:00 PM   #4 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

Quote:
NSString *path = [[NSBundle mainBundle] pathForResource:@"Tink.caf" ofType:@"caf"];
That.
baja_yu is offline   Reply With Quote
Old 07-22-2011, 06:04 PM   #5 (permalink)
Registered Member
 
Join Date: May 2011
Location: Berlin
Posts: 8
jojo is on a distinguished road
Default

Quote:
Originally Posted by baja_yu View Post
Isn't it obvious?

My guess is the problem is the extra extension in the pathForResource call.
this is the code
don't know how the smiley got there/////

[NSURL fileURLWithPath: path] error:nil];
jojo is offline   Reply With Quote
Old 07-22-2011, 06:07 PM   #6 (permalink)
Registered Member
 
Join Date: May 2011
Location: Berlin
Posts: 8
jojo is on a distinguished road
Default

Quote:
Originally Posted by baja_yu View Post
That.

NSString *path = [[NSBundle mainBundle] pathForResource:@"Tink" ofType:@"caf"];

thanks you saved the day
jojo is offline   Reply With Quote
Reply

Bookmarks

Tags
avaudioplayer, error

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 404
16 members and 388 guests
7twenty7, blasterbr, buggen, chiataytuday, Clouds, dre, fiftysixty, HemiMG, jeroenkeij, jimmyon122, jonathandeknudt, LEARN2MAKE, n00b, nyoe, pungs, UMAD
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,668
Threads: 94,121
Posts: 402,901
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jonathandeknudt
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:58 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0