[AC-5081] iOS: 6.1.1 GA / removeEventListener under addEventListener without error?
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Needs more info |
Resolution Date | 2017-07-19T18:50:56.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | n/a |
Reporter | Maxim Khrichtchatyi |
Assignee | Shak Hossain |
Created | 2017-07-12T17:51:54.000+0000 |
Updated | 2017-07-19T18:50:56.000+0000 |
Description
Titanium SDK 6.1.0 GA – the below code works successfully
Titanium SDK 6.1.1 GA – Error
[ERROR] : message = "Invalid type passed to function";
[ERROR] : nativeLocation = "-[TiProxy addEventListener:] (TiProxy.m:838)";
[ERROR] : nativeReason = "expected: Function, was: String";
Help to fix the bug and correct me if I did something wrong.
var avatar = {
RemoteImage: function(a) {
a = a || {};
var md5;
var needsToSave = false;
var savedFile;
if (a.image) {
md5 = Ti.Utils.md5HexDigest(a.image) + '.png';
savedFile = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, md5);
if (savedFile.exists()) {
a.image = savedFile;
}
else {
needsToSave = true;
}
}
if (needsToSave == true) {
var image = Ti.UI.createImageView(a);
function saveImage(e) {
image.removeEventListener('load', saveImage);
savedFile.write(
image.toImage(null, true)
);
};
image.addEventListener('load', saveImage);
function defaultAvatar(e) {
image.setImage(a.data_user_avatar_default);
image.removeEventListener('error', defaultAvatar);
};
image.addEventListener('error', defaultAvatar);
}
else {
var image = Ti.UI.createImageView(a);
}
return image;
}
};
var profileAvatar = avatar.RemoteImage({
image: 'https://www.gravatar.com/avatar/image.png',
data_user_avatar_default: 'https://www.gravatar.com/avatar/md5.png',
defaultImage: '/img/avatar_preload.png',
width: 60,
height: 60
});
Hello, please share a full reproducible test code.