iphone - Image not getting saved (download) in iOS 4.3 -


i'm using

     uiimage *viewimage = [uiimage imagewithdata:[nsdata datawithcontentsofurl:[nsurl  urlwithstring:self.imageurl]]]; nslog(@"uiimage : %@",viewimage); alassetslibrary *library = [[alassetslibrary alloc] init];  [library writeimagetosavedphotosalbum:[viewimage cgimage] orientation:(alassetorientation)[viewimage imageorientation] completionblock:^(nsurl *asseturl, nserror *error){  if (error) {     nslog(@"error"); } else {     nslog(@"url  %@", asseturl);     [self assigndictonary:viewimage withurl:asseturl withmediatype:@"public.image"];  } }]; [library release]; 

or

 dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_default,(unsigned long)null), ^(void) { uiimagewritetosavedphotosalbum([uiimage imagewithdata:[nsdata datawithcontentsofurl:[nsurl urlwithstring:self.imageurl]]], self, @selector(image:didfinishsavingwitherror:contextinfo:), nil); }); 

to save image..

it's working fine versions above ios 5...

it's not working ios 4.3...

why so.. , can 1 suggest me other solution..

i think issue image loading after try invoke saving image assets library.

an alternative approach use nsurlconnection download image, rather trust

+[nsdata datawithcontentsofurl:] method. how i'd on ios5+:

  nsurl *imageurl = [nsurl  urlwithstring: @"https://i.chzbgr.com/maxw500/7335737088/h25ea2f17/"];   nsurlrequest *request = [nsurlrequest requestwithurl: imageurl];   [nsurlconnection sendasynchronousrequest:request                                      queue: [nsoperationqueue mainqueue]                          completionhandler:^(nsurlresponse *response, nsdata *data, nserror *error)    {      uiimage *viewimage = [uiimage imagewithdata: data];      alassetslibrary *library = [[alassetslibrary alloc] init];       [library writeimagetosavedphotosalbum: [viewimage cgimage]                                orientation: (alassetorientation)[viewimage imageorientation]                            completionblock:       ^(nsurl *asseturl, nserror *error)       {         if (error)         {           nslog(@"error");         }         else         {           nslog(@"url  %@", asseturl);         }       }];      nslog(@"uiimage : %@",viewimage);    }]; 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -