views:

20

answers:

1

Hey so i am trying to give my music player a path from which it will find the music file to play but i have one question. Is it possiable to read the pathForResource from a text field instead?

I have a table view, whena row is clicked a new view pops up where the sound will be played.

Regular:

NSString * pathToMusicFile = [[NSBundle mainBundle] pathForResource:@"Katy" ofType:@"mp3"]; 

I Want

NSString * pathToMusicFile = [[NSBundle mainBundle] pathForResource:myTextField.text ofType:@"mp3"]; 

Can i give the resouce name via a text field? I tried the above but it will not read it.

A: 

Are you sure that myTextField.text is actually the string that you entered? Try doing a simple NSLog.

If your "regular" code works, but not your "I Want" code, then it's 99% likely that myTextField.text simply isn't what you think it is.

(As a side question, does your "regular" code work?)

David Liu