Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Build a Playlist Browser with Swift Using a Navigation Controller With Segues Modifying the UI

Christoph Müller
Christoph Müller
7,282 Points

'UIButton' does not have a member named 'text'

Running the app failed in the 'PlayListDetailViewController' because of the the line

buttonPressLabel.text = segueLabelText

Here Xcode tells me "'UIButton' does not have a member named 'text'". I downloaded the Xcode files from the course but it also happens on your code. I'm using Xcode 6.3.

Thanks for your help!

9 Answers

Hi Cristoph, Thanks for the response. I think I may have figured out the issue here. Do you see the line where you declared the outlet for the label? It's on line 13. At the end of this line, after the colon, it says "UIButton!". Change this to "UILabel". I believe this should fix your problem.

Best Regards, Aayush

I don't have that line in my file. Here is my PlaylistDetailViewController code, please tell me how it differs from yours.

import UIKit

class PlaylistDetailViewController: UIViewController {


    var playlist: Playlist?

    @IBOutlet weak var playlistCoverImage: UIImageView!
    @IBOutlet weak var playlistTitle: UILabel!
    @IBOutlet weak var playlistDescription: UILabel!

    @IBOutlet weak var playlistArtist0: UILabel!
    @IBOutlet weak var playlistArtist1: UILabel!
    @IBOutlet weak var playlistArtist2: UILabel!






    override func viewDidLoad() {
        super.viewDidLoad()

        if playlist != nil {
            playlistCoverImage.image = playlist!.largeIcon
            playlistCoverImage.backgroundColor = playlist!.backgroundColor
            playlistTitle.text = playlist!.title
            playlistDescription.text = playlist!.description

            playlistArtist0.text = playlist!.artists[0]
            playlistArtist1.text = playlist!.artists[1]
            playlistArtist2.text = playlist!.artists[2]



        }






    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }



}

Can you send a screenshot of your code? You may have accidentally control-dragged the view instead of the label into your view controller class. Please send a snapshot of your code so I can verify this

Christoph Müller
Christoph Müller
7,282 Points

Hi Aayush

As I wrote, It doesn't matter if I'm using my code or the one Pasan offers to download. It won't work. Please see my code an the error here:

http://www.screencast.com/t/Db8jCX9DZs

Thanks for your help

Christoph

Thanks Cristoph, I think I have figured out the solution. If you take a look at the picture of your code, you will notice that there is a empty circle on line 13. It is to the left of the line number. This empty circle means that the outlet isn't actually connected to a UI element. Try deleting the code and reconnecting the UIButton to an outlet. That should fix the problem. Best Regards, Aayush Manocha

Christoph Müller
Christoph Müller
7,282 Points

Hi Aayush

Once again, thanks for your help. Good point with the empty circle (learned something new). How ever it that wasn't the issue. Please see my screenshot with the connected outlet.

http://www.screencast.com/t/WSr4fddW3

Please be aware that I'm using the code Pasan (or Treehouse) offers to download... since I was not sure if I made up an error.

Thanks for your effort on helping me

Christoph

Christoph Müller
Christoph Müller
7,282 Points

Hi Aayush

That was the solution. Still it needed some more syntax fixes:

http://www.screencast.com/t/CaEbBAv9Z4

Line 19 needs an "!" at "buttonPressLabel!.text = segueLabelText"

Thanks, now it works and I can move on!

Regards Christoph

Petar Zelenovic
Petar Zelenovic
11,356 Points

Sorry for being late, but I think the real root of the problem lies in the fact that you're using a button control as if it's a label. A button does not have a property "text". If you want to set the text of the button use the method setTitle(string, forState: .Normal)