Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deferenced value assignment on iOS error #13952

Open
1 task done
Informate opened this issue Dec 10, 2023 · 0 comments
Open
1 task done

Deferenced value assignment on iOS error #13952

Informate opened this issue Dec 10, 2023 · 0 comments
Labels
bug ios needs triage This issue hasn't been reviewed by maintainers

Comments

@Informate
Copy link

Informate commented Dec 10, 2023

I have searched and made sure there are no existing issues for the issue I am filing

  • I have searched the existing issues

Description

I have one object with some attributes nested in a UI.View, inside another UI.View.

obj={attribute1: 'Wrong value'};
view1.obj=obj;
view2.view1=view1;

I havean eventlistener on the view2 for touch events.

view2.addEventListener('touch_start',func1);

Inside the listener function I deference the objects into constants starting from the event source element.

function func1(e) {
 const view2=e.source,
   view1=view2.view1,
   obj=view1.obj;

Now if I update the obj attrbutes, for eample:

 obj.attribute1 = 'Correct value';

On Android the code works correctly, on iOS it not works!
When I call another funcion and dereference the obj again the changes are lost! ( I am using transpile = true )

  func2(view2);

It seems that the object is somewhere cloned in the const assigment process, loosing the reference in the original object but it happens only on iOS.

function func2(view2) {
 console.log(view2.view1.obj.attribute1);
}

Anyway there is an easy workaround to fix this problem. You can just do:

 if (!OS_ANDROID) view2.view1.obj=obj;

And everything will work also on iOS.

Expected Behavior

view2.view1.obj.attribute1 = 'Correct Value';

Actual behavior

view2.view1.obj.attribute1 = 'Wrong Value';

Reproducible sample

Not ready at the moment

Steps to reproduce

Not ready at the moment

Platform

iOS

SDK version you are using

12.1.2.GA

Alloy version you are using

No response

@Informate Informate added bug needs triage This issue hasn't been reviewed by maintainers labels Dec 10, 2023
@m1ga m1ga added the ios label Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ios needs triage This issue hasn't been reviewed by maintainers
Projects
None yet
Development

No branches or pull requests

2 participants