dododedodonl
dododedodonl

Reputation: 4605

Background Thread -> update UI

I'm downloading and parsing a XML document. During this, I want to update my UIProgressView. I know I have to do this in the main thread, and not in the background thread where the document gets parsed.

But my problem is, when I try this:

[self performSelectorOnMainThread:@selector(setProgressStr) withObject:[NSString stringWithFormat:@"%f", updateTo] waitUntilDone:NO];

I send it via a NSString, because a float won't work. But now I get the next error:

-[TDFetch setProgressStr]: unrecognized selector sent to instance 0x6b9a700

What am I doing wrong?

Upvotes: 1

Views: 573

Answers (2)

Vitaly S.
Vitaly S.

Reputation: 2389

Looks like you forgot about ':' after name of selector. Try

[self performSelectorOnMainThread:@selector(setProgressStr:) withObject:[NSString stringWithFormat:@"%f", updateTo] waitUntilDone:NO];

Upvotes: 2

jscs
jscs

Reputation: 64002

If the method you're trying to use takes an argument, that means that it has a colon in the name -- the colon is actually a part of the name. You need to include that when you get the selector:

@selector(setProgressStr:)

Upvotes: 4

Related Questions