3

I have a public function:

public func lastActivityFor(userName: String) -> String { ... }

and later I want to call it as:

OneLastActivity.lastActivityFor("username")

but the last line get error:

Cannot convert value of type 'String!' to expected argument type 'OneLastActivity'

Why it appears if I send to those function String as suggested?(userName: String)

Any ideas how can I fix it? If you want more code, just ask me about.

1 Answer 1

6

Just create an instance of your class this way:

let temp = OneLastActivity()

Now you can use it's method:

temp.lastActivityFor("username")

Or you can directly use it this way:

OneLastActivity().lastActivityFor("username")

Hope it helps.

Sign up to request clarification or add additional context in comments.

2 Comments

Oh, I found answer at the same time with you )) I used OneLastActivity.sharedInstance.lastActivityFor("username")
@DharmeshKheni sir answer this related question please, stackoverflow.com/questions/42733225/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.