开发者

load pathForResource from a text field?

开发者 https://www.devze.com 2023-01-12 17:55 出处:网络
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?

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 wil开发者_如何学Gol 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.


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?)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号