私はsqliteデータベースに画像を保存する必要があるプロジェクトに取り組んでいます。 NSDataをNSStringに変換しようとすると、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.");
}
私は我々は、このリンクからBase64のライブラリをダウンロードする必要があり、あなたに
だけで、データが前にフェッチないのデータベースに挿入されているチェック... – vaibhav
私は、クエリを介してデータを挿入しています。データがない場合は、どうすればそれを取得できますか? –
おそらく、あなたのデータはdb内に存在していないでしょう。イメージデータを含む文字列をダブルチェックするだけです。 – vaibhav