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 04-09-2010, 08:05 AM   #1 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 64
oztemel is on a distinguished road
Default Pickerview file choosing

Hi,
I'm new at board and also sdk...
I would like to choose file from the pickerview and play by button. I write that code but not working.. please help me to fix it.. file names are 0.caf , 1.caf, 2.caf...

- (void)pickerViewUIPickerView *)pickerView didSelectRowNSInteger)row inComponentNSInteger)component{

NSString *path = [[NSBundle mainBundle] pathForResource:row ofType:@"caf"];
NSURL *file = [[NSURL alloc] initFileURLWithPathath];

AVAudioPlayer *p = [[AVAudioPlayer alloc] initWithContentsOfURL:file error:nil];

[file release];
self.player = p;
[p release];
[player prepareToPlay];
[player setDelegate:self];
}
oztemel is offline   Reply With Quote
Old 04-09-2010, 09:22 AM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

Quote:
I write that code but not working
Can you be more specific? Does it compile? Does it crash when you select a row?
smithdale87 is offline   Reply With Quote
Old 04-09-2010, 09:38 AM   #3 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 64
oztemel is on a distinguished road
Default

compiled but 1 warning.. when I change the picker program terminating..
warning message is:

passing argument 1 of pathforResourcefType: makes pointer from integer without a cast
oztemel is offline   Reply With Quote
Old 04-09-2010, 10:08 AM   #4 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

Warnings are your friends!

Are your image files names "0.png", "1.png", ... ?

Also change this:
Code:
NSString *path = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%d",row] ofType:@"caf"];
smithdale87 is offline   Reply With Quote
Old 04-09-2010, 10:13 AM   #5 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 64
oztemel is on a distinguished road
Default

thank you so much... it's working
oztemel is offline   Reply With Quote
Old 04-09-2010, 10:21 AM   #6 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

you're welcome!
smithdale87 is offline   Reply With Quote
Reply

Bookmarks

Tags
audio player, pickerview

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: 313
15 members and 298 guests
chemistry, Domele, Fstuff, givensur, heshiming, HowEver, iAppDeveloper, iphonedevshani, jbro, JoeRCruso, kapps11, newDev, SLIC, stanny, WheyLabs
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,648
Threads: 94,112
Posts: 402,874
Top Poster: BrianSlick (7,990)
Welcome to our newest member, brandon6031
Powered by vBadvanced CMPS v3.1.0

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