当前位置: 动力学知识库 > 问答 > 编程问答 >

ios - How to update NSURL from dispatch_queue_t?

问题描述:

I have some problem with dispatch_queue_t queue. I tried to found perfect solution for my problem but i found solution for load UIImage or another elements but not for NSURL. So i have simple NSURL with simple site:

NSURL *url = [NSURL URLWithString:@"site.ch"];

NSURLRequest *request = [NSURLRequest requestWithURL:url];

I need that my NSURL (This code which up)will reboot after for example 10 min, so for time i put NSTimer, but for update this NSURL i tried to used this code but i have error also..

-(void)updateRadio

{

dispatch_queue_t queue = dispatch_get_global_queue(0,0);

dispatch_async(queue, ^{

NSError* error = nil;

NSString* text = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"site.ch"]

encoding:NSASCIIStringEncoding

error:&error];

// checking if error == nil would be appropriate

dispatch_async(dispatch_get_main_queue(), ^{

});

});

}

SO i need to put NSURL With Request to this code with dispatch. Not NSString only NSURL

How this made?Thanks.

网友答案:

If I understand you correctly you have error because of incorrect encoding. Try to use NSUTF8StringEncoding instead.

分享给朋友:
您可能感兴趣的文章:
随机阅读: