Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Cannot access a function member using dot notation swift

I cannot access the playerAv() function's elements outside of the function. How can I access it?

And also I tried to remove the function and use these lines outside of any function and I got an error in the second line. Why I couldn't assign audioLink value outside of a function?

var audioLink = "http://www.liveatc.net/play/ltba.pls"  //I got an error here:(
var player:AVPlayer = AVPlayer(URL: NSURL(string: audioLink))

let pa = playerAv()
pa.player.volume = currentValue
println(currentValue)

//
//Another try


 func playerAv(){
        var audioLink = "http://www.liveatc.net/play/ltba.pls"
        var player:AVPlayer = AVPlayer(URL: NSURL(string: audioLink))
    }

@IBAction func sliderValueChanged(sender: UISlider) {
        var currentValue = Float(sender.value)
        println(currentValue)
        player.volume = currentValue //I got an error here:(
    }

Thanks