osx - How update image from URL in OS X app? -


i have problem. have code update song name , picture php. song name work , updated picture not work, in php file work in project - no. how make update picture url after 10 sec example. thanks.

-(void)viewwilldraw {      nsurl *artistimageurl = [nsurl urlwithstring:@"http://site.ru/parsedatafield/kiss.php?image"];      nsimage *artistimage = [[nsimage alloc] initwithcontentsofurl:artistimageurl];      [dj setimage:artistimage];      dispatch_queue_t queue = dispatch_get_global_queue(0,0);      dispatch_async(queue, ^{      nserror* error = nil;          nsstring* text = [nsstring stringwithcontentsofurl:[nsurl urlwithstring:@"http://site.ru/parsedatafield/kiss.php?artist"]                                                 encoding:nsasciistringencoding                                                    error:&error];          dispatch_async(dispatch_get_main_queue(), ^{              [labelname setstringvalue:text];           });     }); } 

you should consider placing code someplace other -viewwilldraw. routine can called multiple times same nsview under circumstances and, more importantly, need call [super viewwilldraw] make sure things draw correctly (if drawn in view itself).

for periodic updates (such every 10 seconds), should consider using nstimer trigger retrieval of next object.

as general question of why image isn't being drawn correctly, should consider putting image retrieval , drawing code same structure label retrieval , drawing code. [dj setimage: artistimage] method call outside of viewwilldraw chain causing difficulty here.


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -