저는 sqlite 데이터베이스에 이미지를 저장해야하는 프로젝트에서 작업하고 있습니다. NSString NSData 변환 할 때 그것은 nil 값을 반환합니다.데이터를 문자열로 변환하면 nil 값이됩니다.
여기 내 코드입니다.
imageData = [[NSData alloc]initWithBytes:UIImagePNGRepresentation(self.img_userprofile.image).bytes length:UIImagePNGRepresentation(self.img_userprofile.image).length];
NSString *charlieSendString = [[NSString alloc] initWithData:imageData encoding:NSUTF8StringEncoding];
NSString *query = [NSString stringWithFormat:@"insert into Friends values(null, '%@', '%@', '%@')", self.txt_name.text,charlieSendString, self.txt_mobile_no.text ];
[self.dbManager executeQuery:query];
// If the query was successfully executed then pop the view controller.
if (self.dbManager.affectedRows != 0) {
NSLog(@"Query was executed successfully. Affected rows = %d", self.dbManager.affectedRows);
}
else{
NSLog(@"Could not execute the query.");
}
것은 나에게 감사 도움말
그냥 데이터를 확인는 내가 쿼리를 통해 데이터를 삽입하고 전에 가져 오지의 데이터베이스 .. – vaibhav
에 삽입됩니다. 데이터가 없으면 어떻게 가져올 수 있습니까? –
아마 당신의 데이터가 db 안에 존재하지 않을 것입니다. 단지 이미지 데이터를 포함하고있는 당신의 문자열로 그것을 다시 체크하거나 뭔가 잘못되었습니다. – vaibhav