Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use same file name in different folder in xcode and how to access it in ios Swift language

I am working on audio player in iOS 8 in Swift language.

I have an audio file name with "apple.mp3" in both male and female voices same audio name. Both files are two different groups, for male male group and for female audio female group. So paths would be male/apple.mp3 and female/apple.mp3.

I am using following code to play an audio file

    var audioPlayer = AVAudioPlayer()
    var currentAudioPath:NSURL!
    currentAudioPath = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource(audioName, ofType: "mp3")!)

    AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, error: nil)
    AVAudioSession.sharedInstance().setActive(true, error: nil)
    UIApplication.sharedApplication().beginReceivingRemoteControlEvents()
    audioPlayer = AVAudioPlayer(contentsOfURL: currentAudioPath, error: nil)
    audioPlayer.delegate = self
    audioPlayer.play()

    audioPlayer.prepareToPlay()

How can I play both audios separately with specific path?

like image 316
sudheer Avatar asked Nov 10 '14 07:11

sudheer


People also ask

How do I move an Xcode project to another folder?

1. Click each group, then click the square icon (see screenshot below) and choose the folder your project file is in. "None" will show up when you choose the same folder your .

How do I import a folder into Xcode?

Importing into XcodeOpen Xcode and select Open Another Project or File, Open. Open the folder you unzipped from your Dropsource download and locate the file with “. xcodeproj” extension in the root directory. Select the file and click Open.

How do I search and open files in Xcode?

In xcode on left pane in the project navigator at the bottom there is a search field. In the documentation it is called filter bar. According to Inder Kumar Rathore the shortcut is ⌘ + ⇧ + O .

How do I change a filename in Xcode?

Select the project you want to rename in the “Project Navigator” which can be found on the left side of the Xcode view. On the right-hand side of the window, select the “File Inspector”. The name of your project should be in there under “Identity and Type”, change it to “NEW” and press Enter.


1 Answers

To the best of my knowledge, if you have similar file names anywhere in the project, no matter how deep in a subfolder, Xcode will complain about duplicate resources. When you ask for an image by name, Xcode 'sees' the whole project, that's the up side.

In short, no, you cannot have two resources with identical name in the same project. It is advised to give a unique name to each one.

like image 200
bauerMusic Avatar answered Oct 05 '22 17:10

bauerMusic