views:

23

answers:

1

Hi all,

Can someone please point me in the right direction... I need to use the same sound (a button press) throughout all view controllers in my app. What is the best way to do this. I have managed to load and play a sound in a single view controller but cannot manage to pass a sound to different viewcontrollers because SystemSoundID is not an object and so I cannot use it as a property?? Can someone please help as this is driving me crazy and Im sure its something simple that Im missing!!

Many thanks

Jules

A: 

You can define the property like this:

@property (assign) SystemSoundID clickSound;

Then when you create your view controller, you can set it thusly:

viewController.clickSound = aSoundID;

lucius
Thanks for the answer.... Ive never been to sure on the differences between, copy, assign and retain. I was trying to use retain which was giving me an error but assign seems to work?? If you'd be so good as to explain this Id really appreciate it.Many thanksJules
Jules
Copy sends the -[copy] message to the object and stores the result in the ivar, but for immutable objects it usually is the same as a retain, so only mutable objects result in a new copy being made of the object. Retain increments the retainCount of the object and the ivar points to the same object that was passed in. Assign just sets the ivar to point at the object without changing the retainCount.
lucius