ios - AFNetworing - setImageWithURLRequest not working -


i want set tableview cell images in 1 of apps. use afnetworking (1.2.1) , setimagewithurlrequest.

my code in set images looks this:

    if (user.avatar) {         nsstring *imageurl = user.avatar.url;          [cell.profileimage setimagewithurlrequest:[nsurlrequest requestwithurl:[nsurl urlwithstring:imageurl]] placeholderimage:nil success:^(nsurlrequest *request,   nshttpurlresponse *response, uiimage *image) {             [cell setneedslayout];         } failure:^(nsurlrequest *request, nshttpurlresponse *response, nserror *error) {             nslog(@"error: %@", error);         }];     }  

my error log returns this:

error: error domain=nsurlerrordomain code=-999 "the operation couldn’t completed.   (nsurlerrordomain error -999.)" userinfo=0x1f5b56a0  {nserrorfailingurlkey=https://d2rfichhc2fb9n.cloudfront.net/image/5/cf7t_ba6- nfgl5ah0w4hdvmk_vp7inmioijzmyisimiioijhzg4tdxnlci1hc3nldhmilcjrijoiyxnzzxrzl3vzzxivztivm2mvmja vztizyziwmdawmdawmdawmc5qcgcilcjvijoiin0} 

and images dosn't set. didn't have problem before updated afnetworking (1.2.1). ideas?

update

tried strip whitespace url this:

nsstring *imageurl = [user.avatar.url stringbytrimmingcharactersinset:[nscharacterset whitespaceandnewlinecharacterset]]; 

but same error. , maybe dangerous if api sometime contain image file name contains whitespaces.

i see 3 problems:

  1. -999 means nsurlerrorcancelled, looks urlrequest gets cancelled somehow. code of yours? possible cell object or uiimageview profileimage released prematurely?

  2. more recent versions of afnetworking require set image if you're defining success block.

  3. make sure url valid.

try (works when placed in tableview:cellforrowatindexpath:):

__weak uitableviewcell *weakcell = cell; [cell.imageview setimagewithurlrequest:[nsurlrequest requestwithurl:[nsurl urlwithstring:imageurl]] placeholderimage:nil success:^(nsurlrequest *request,   nshttpurlresponse *response, uiimage *image) {     if (weakcell)     {         weakcell.imageview.image = image;         [weakcell setneedslayout];     } } failure:^(nsurlrequest *request, nshttpurlresponse *response, nserror *error) {     nslog(@"error: %@", error); }]; 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -