+[NSData dataFromBase64String:]: unrecognized selector sent to class
emnloc opened this issue · 6 comments
This message appears and the app crashes.
I'm using cordova 5
My code is:
cordova.base64ToGallery(
canvas.toDataURL().replace('data:image/png;base64,', ''),
'img_',
function(msg){
console.log(msg);
},
function(err){
console.log(err);
}
);
Hello emnloc,
which version of Xcode and iOS are you using?
And you don't need to call the replace() method on dataUrl stringe because the plugin already do that.
@StefanoMagrassi I'm using Xcode 7.2 and ios 9.2
@emnloc it could be a problem with NSData+Base64.h class that, according to cordova-ios documentation, seems to have been removed from version 4.0 of the platform.
I wrote this plugin for a specific project and maybe I was lucky (Xcode warns me about deprecated methods, but the app runs well anyway).
I can't fix it now, but I will probably start working on it tomorrow.
If you can't wait, you can try to edit the Base64ToGallery.m script and maybe send a PR.
@emnloc I probably fixed the issue.
Please, checkout the "issue#3" branch and make some test.
I've tried with my cordova application on a Macmini with Xcode 7.2: no warnings or errors and the image was saved on the device. But I need to be more confident before merging it in "master" branch and publishing it on npm.
Tell me if have some troubles with the tests.
@StefanoMagrassi it works fine, I've tested in on my iPad mini and the simulator.
Great job!! 👏 👏
@emnloc ok, perfect.
I cannot merge the branch now, but I wil do it during the day.
When I'll close the issue you will find on npm (and here obviously) the new plugin version