Tweet not showing variable as string?

51 Views Asked by At

I've created a small app to get the clipboard on IOS using swift, but when I try to tweet the variable, it's not showing up as a string, it shows up as

<UILabel: 0x146db1a30; frame = (78.6667 229; 257 147); text = 'I'm on my way right now'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x146db1fd0>>

instead of

\(clipText)

The code I have to get the clipboard contents is

let pasteboardString:String? = UIPasteboard.generalPasteboard().string
clipText.text = pasteboardString`

When I go to post the tweet using this code

let tweetController = SLComposeViewController(forServiceType: SLServiceTypeTwitter)
tweetController.setInitialText("Here's what was on my clipboard:(clipText)")

I get the text from the top instead.

Image of the code I get instead of (clipText)

1

There are 1 best solutions below

3
C0mrade On
let pasteboardString:String? = UIPasteboard.generalPasteboard().absolutString
clipText.text = "\(pasteboardString)"

But you do not need to post UILabel The message is correct because you are trying to post UILabel object. instead of this try to post only string or UILabel's text

instead of "\(clipText)" use "\(clipText.text)"