Hi All,
Im developing native iOS application using sup 2.1.3 . Im getting error While retrieving image from SUP database. Here i'm trying to get image from database and show in imageView.can any one help me how to fix this issue?
In database image datatype is 'LONG Binary' .
My table Schema:
CREATE TABLE dba.ImagesTable (
RowID INT NOT NULL,
ImageName VARCHAR(20) NOT NULL,
PhotoData LONG BINARY NOT NULL,
)
IN SYSTEM
;
ALTER TABLE dba.ImagesTable
ADD CONSTRAINT ASA137 PRIMARY KEY CLUSTERED (RowID)
;
ALTER TABLE dba.ImagesTable
ADD CONSTRAINT ASA138 UNIQUE NONCLUSTERED (RowID)
;
in Xcode:
[SUP107SUP107DBsynchronize];
SUP107ImagesTable *imgTable =[[SUP107ImagesTablealloc]init];
SUP107ImagesTableList *list =[SUP107ImagesTablefindAll];
SUP107ImagesTable * oneRecord =[list objectAtIndex:0];
NSLog(@"rowId:%d---imageName:%@---photoData:%@---photoLenght:%d",oneRecord.rowID,oneRecord.imageName,oneRecord.photoData,oneRecord.photoDataLength);
NSData *tempData =[[NSDataalloc]init];
SUPBigBinary *responseBinaryData = (SUPBigBinary *)oneRecord.photoData.value;
@try {
[responseBinaryData openForWrite:[oneRecord.photoDatalength]];
[responseBinaryData write:tempData];
}
@catch (NSException *exception) {
NSLog(@"exception: %@",[exception description]);
}
UIImageView *imgView =[[UIImageViewalloc] initWithFrame:CGRectMake(50,50,100,100)];
[self.windowaddSubview:imgView];
UIImage * tempImage =[UIImageimageWithData:tempData];
imgView.image = tempImage;
[responseBinaryData close];
Error Log:
Printing description of list:
[ ImagesTable =
rowID = 1,
imageName = Apple,
photoData = SUPBigBinary: column=c pending=1 allow_pending_state=1 table=sup107_1_0_imagestable mbo=0x0 key=(null) ,
pending = 0,
pendingChange = N,
replayPending = 0,
replayFailure = 0,
surrogateKey = 300001,
replayCounter = 0,
disableSubmit = 0,
photoDataLength = 90656,
isNew = 0,
isDirty = 0,
isDeleted = 0,
]
2014-04-02 18:42:15.150 SUP102[2873:70b] rowId:1---imageName:Apple---photoData:SUPBigBinary: column=c pending=1 allow_pending_state=1 table=sup107_1_0_imagestable mbo=0x0 key=(null) ---photoLenght:90656
Printing description of responseBinaryData:
<OS_dispatch_data: data[0xc891b40] = { leaf, size = 90656, buf = 0x1213a000 }>
2014-04-02 18:42:33.304 SUP102[2873:70b] -[OS_dispatch_data openForWrite:]: unrecognized selector sent to instance 0xc891b40
2014-04-02 18:42:33.305 SUP102[2873:70b] exception: -[OS_dispatch_data openForWrite:]: unrecognized selector sent to instance 0xc891b40
2014-04-02 18:42:33.305 SUP102[2873:70b] -[OS_dispatch_data close]: unrecognized selector sent to instance 0xc891b40
2014-04-02 18:42:33.306 SUP102[2873:70b] [ERROR] [AppDelegate.m:497] NSInvalidArgumentException: -[OS_dispatch_data close]: unrecognized selector sent to instance 0xc891b40
can any give some help how to fetch PhotoData and show that one in UIImageview in ios?