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 Build a Simple iPhone App with Swift 2.0 Getting Started with iOS Development Swift Recap Part 1

swift_lint.swift:13:57: error: cannot convert value of type 'Tag.Type' to expected argument type 'Tag'

I've got no clue how this compiler expects me to finish this exercise.

swift_lint.swift:13:57: error: cannot convert value of type 'Tag.Type' to expected argument type 'Tag'

structs.swift
struct Tag {
    let name: String
}

struct Post {
  var title: String
  var author: String
  var tag: Tag
}

let firstPost = Post(title: "First", author: "Me", tag: Tag)

7 Answers

Hi there,

Your Tag object needs creating; i.e. pass it a name:

let firstPost = Post(title: "First", author: "Me", tag: Tag(name: "swift"))

Make sense?

Steve.

Hi Fiodar,

You're fine with your code except with the tag parameter. The constructor for Post takes three parameters. both title and author are of data-type, String. In your example code you have passed in an empty string to those parameters, which is fine.

The third parameter, tag needs an instance of data type Tag. This means that you need to create an instance of Tag in your call to the constructor of Post. Currently, you have passed an empty string into the tag parameter. If we look at the class itself, Tag does only require a string to be 'complete'. However, we need to call the constructor.

So, just as you have called the Post constructor by using the Post(title: "", author: "") format, you need to do the same for the Tag class. A Tag wants a string so can be created with a constructor call like, Tag(name: "string").

Insert that into your creation of a Post looks like:

let firstPost = Post(title: "", author: "", tag: Tag(name: "swift")

You may want to amend your first two strings to pass the tests the challenge is wanting, i.e. change the empty strings to something it is asking for - don't know. But, doing the above will pass an instance of Tag into the Post constructor, rather than just a string.

I hope that helps - let me know if you have questions. Just ask, I will try to help further.

Steve.

Kenneth Dubroff
Kenneth Dubroff
10,612 Points

It would be nice to have gone over the Tag type before this. It's not in the iOS beginner track. I tried sorting through it in Xcode, but Tag isn't recognized as a data type in Xcode 8. The only google posts pertaining to this mystery data type that came up in a quick google search were treehouse posts.

Hi Kenneth,

The Tag type is a struct created at the top of this code challenge - it isn't an iOS thing.

You'll not find any docs on it for that reason. If you have any queries about how it works, just shout.

Steve.

Thank you Steve!

:+1:

Kenneth Dubroff
Kenneth Dubroff
10,612 Points

I see that now thanks. I came here to delete my comment lol

:+1: :wink:

Because the Tag needs to be set as well. Thanks Steve!

No problem - glad you got it sorted. :wink:

Steve.

struct Tag {
    let name: String
}

struct Post {
    var title: String
    var author: String
    var tag: Tag

}
let firstPost = Post(title: "", author: "", tag: "") 

I Need help! Dont understand what to do with that tag, keep gettng an error on it.