0

I am fetching an image from a URL to set it as a background image of WKInterfaceGroup in a watch app but it is taking too much time (around 20 seconds) to load the background image, I seem to have used the most preferred method but I am not able to figure out why it is taking so long to load an image... The following is my code:

   -(void) watchData:(WatchJSONParser *)data
    {
        int type = (int)data.sourceType;
      watchUserData = data.watchDataDict;

        NSLog(@"watchUserData:%@", watchUserData);
        switch (type)
        {
            case DataConnectionSourceTypeUserData:
                if([watchUserData objectForKey:@"userData"])

                {

                    skpImgServerUrl = [[watchUserData objectForKey:@"userData"] objectForKey:@"imageServerURL"];

                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
                               ^{
                        NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",skpImgServerUrl,[[watchUserData objectForKey:@"userData"] objectForKey:@"tenantLogo"]]];
                        NSData *data = [NSData dataWithContentsOfURL:url];

                      NSLog(@"ASY thread:%@", url);
                        dispatch_async(dispatch_get_main_queue(), ^{
                          //[self.homeBgGroup setBackgroundImage:placeholder];
                      [self.homeBgGroup setBackgroundImageData:data];
                            [statusLabel setHidden:YES];


                        });
                    });

                }
                break;
            default:
                break;
        }
    }
Dmytro Hutsuliak
  • 1,741
  • 4
  • 21
  • 37
jayant rawat
  • 318
  • 2
  • 12

0 Answers0