ios - Retrieving images from ALAssetLibrary into object property -


i have model class manages of local sqlite3 calls, model class defines properties system object , table display information retrieved objects. database management class retrieves of data locally.

the issue having images retrieved using alassetslibrary. retrieval done in block runs on separate thread. cannot figure out how image store correct property. image information stored in sqlite database [nsurl absolutepath]. allows me grab path , send alassetslibrary calls.

datamodel class

- (nsarray *)requestobjects {      // local variables     nsarray *queryarray = nil;     nsstring *query = nil;     nsmutablearray *objectarray = [[nsmutablearray alloc] init];     sqlwrapper *sql = [[crsqlwrapper alloc] initwithpath:@"mydb.sqlite"];      // create query     query = @"select * objects";      // execute query     queryarray = [sql performquery:query];      // turn results objects     (int = 0; < [queryarray count]; i++) {         myclass *object = [[myclass alloc] init];         // here want iterate , image alassetlibrary each object          [objectarray addobject:object];     }      return objectarray; } 

the code have found retrieve these images:

alassetslibraryassetforurlresultblock resultblock = ^(alasset *myasset) {     alassetrepresentation *rep = [myasset defaultrepresentation];     cgimageref iref = [rep fullresolutionimage];     if (iref) {         uiimage *image = [uiimage imagewithcgimage:iref];         nslog(@"image retrieved!");         [self.delegate imageavailable:image];     } };  alassetslibraryaccessfailureblock failureblock  = ^(nserror *myerror) {     nslog(@"failed image: %@", [myerror localizeddescription]); };  nsurl *asseturl = [nsurl urlwithstring:imagepath]; alassetslibrary *assetslibrary = [[alassetslibrary alloc] init]; [assetslibrary assetforurl:asseturl                resultblock:resultblock               failureblock:failureblock]; 

by time block threads finish, table has loaded. behavior of images load , store respective object instances before table loads. assume need send gcd rest of ui (excluding table) continue normal.

any appreciated , if additional information needed let me know!


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -