0

I have some buttons linked to an IBAction that plays a sound.

-(IBAction)listen {
 // play the audio
}

My files are organized with On Demand Resources, and I have 3 tags:

  • level1
  • level2
  • level3

So what I'd like to achieve is:

if the user is on level 1, he will only be able to play files with the level1 tag. If he clicks on a level2 tag audio, an alert will appear.

How can I check if a file has a specific tag?

fabdurso
  • 2,366
  • 5
  • 29
  • 55

1 Answers1

1

I'm not aware of an API to access a resource's ODR tags, so you have to use some other way to map resources to access controls in your app code. Perhaps you can use pathForResource(_:ofType:) to inspect the path of the resource, and if it is in the directory "level2", prevent your user from accessing the resource until they are on the appropriate level?

Palpatim
  • 9,074
  • 35
  • 43
  • so should I have to store my files on different folders in my project? – fabdurso Apr 28 '16 at 22:00
  • That would be one way to do it. I agree it would be convenient for this use case to know what tags are assigned to an asset, but that's a packaging-level detail. You wouldn't want your code to break if you stopped using ODR and started packaging all resources with the app, so it would be better to rely on a different mechanism instead of overloading the tagging mechanism in unexpected ways. – Palpatim Apr 28 '16 at 22:54
  • so if I have level1 folder, level2 folder, level3 folder, how should i check it? – fabdurso Apr 30 '16 at 18:16