iphone - Images not displaying from remote database -


i stored images in remote server. use json framework fetching data database. used nslog displaying id,name,image name. images not displaying. used blob storing images in locally. when use array nslog displaying encript values.

code:

sofarray = [[nsmutablearray alloc] init];         nsfilemanager *filemgr = [nsfilemanager defaultmanager];     nserror *err;      nsstring *bundlepath = [[nsbundle mainbundle] pathforresource:@"empty" oftype:@"sqlite"];     //nslog(@"bundlepath %@", bundlepath);       //call update function check data updated,     //if there version difference     //update data base required fileds.        nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory,nsuserdomainmask, yes);     nsstring *documentsdirectory = [paths objectatindex:0];     //nslog(@"docs dir %@", documentsdirectory);      nsstring *appfile = [documentsdirectory stringbyappendingpathcomponent:@"app10.sqlite"];      [filemgr copyitematpath:bundlepath topath:appfile error:&err];   nsurl *url = [nsurl urlwithstring:@"http://server.net/projects/mobile/jsonstring.php"];      nslog(@"url %@", url);        nserror *error;      nsstring *stringfromfileaturl = [[nsstring alloc]      initwithcontentsofurl:url      encoding:nsutf8stringencoding      error:&error];       //nslog(@"response %@", stringfromfileaturl);       nsstring *path = [documentsdirectory stringbyappendingpathcomponent:@"app10.sqlite"];        nsarray *userdata = [stringfromfileaturl jsonvalue];       // nsarray *skarray = [[nsarray alloc]init];        nslog(@"userdata %@", userdata);     // int  = 0;     bool notexist = true;        (nsarray *skarray in userdata) {       (nsdictionary *tuser in skarray) {     //  if (sqlite3_open([dbpath utf8string], &db) == sqlite_ok) {            if (sqlite3_open([path utf8string], &db) == sqlite_ok) {         //  const char *sql = "select * categories";     //  const char *sql = [[nsstring stringwithformat:@"select id categories cat_id = '%@'",[tuser objectforkey:@"cat_id"]] cstringusingencoding:nsutf8stringencoding];         const char *sql = [[nsstring stringwithformat:@"select id categories id = '%@'",[tuser objectforkey:@"id"]] cstringusingencoding:nsutf8stringencoding];            //nslog(@"check stmt %s", sql);       sqlite3_stmt *sqlstatement,*addstmt;       if (sqlite3_prepare_v2(db, sql, -1, &sqlstatement, null) == sqlite_ok) {         notexist = true;       while (sqlite3_step(sqlstatement) == sqlite_row) {          notexist = false;        mysof *mylist = [[mysof alloc]init];      mylist.sofaid = sqlite3_column_int(sqlstatement, 0);      mylist.sofa = [nsstring stringwithutf8string:(char *) sqlite3_column_text(sqlstatement,1)];      mylist.rating = [nsstring stringwithutf8string:(char *) sqlite3_column_text(sqlstatement, 2)];         const char *raw = sqlite3_column_blob(sqlstatement, 3);      int rawlen = sqlite3_column_bytes(sqlstatement, 3);      nsdata *data = [nsdata datawithbytes:raw length:rawlen];      mylist.photo = [[uiimage alloc] initwithdata:data];      [sofarray addobject:mylist];    }           if(notexist){              //nslog(@"cat id not exist");               const char *sqlinsert = [[nsstring stringwithformat:@"insert categories (id, cat_name,order_by) values ('%@', '%@', '%@')", [tuser objectforkey:@"id"], [tuser objectforkey:@"cat_name"],[tuser objectforkey:@"order_by"]] cstringusingencoding:nsutf8stringencoding];              //nslog(@"stmt %s", sqlinsert);               if(sqlite3_prepare_v2(db, sqlinsert, -1, &addstmt, null) != sqlite_ok)                  nsassert1(0, @"error while creating add statement. '%s'", sqlite3_errmsg(db));               if(sqlite_done != sqlite3_step(addstmt))                  nsassert1(0, @"error while inserting data. '%s'", sqlite3_errmsg(db));           }        }       }       }       }   return sofarray; 


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -