A question about the declaration of public properties in apps
4 次查看(过去 30 天)
显示 更早的评论
Hi! :)
I have a question: if I have declared a property as a public variable in my main app, is it necessary that I also declare it as a private property in the app I am using it.
In my case I have a table Osmotisk_data that I have declared as a public property in the main app, then I am using some of the columns (arrays) from this table in another app, there I have declared it as a private property, but I am a little confused becuase I am not getting the results that I am supposed to get.
0 个评论
回答(1 个)
Steven Lord
2024-10-12
How are you planning to share the data between the two apps? This documentation page offers some guidance on how to do that.
2 个评论
Steven Lord
2024-10-12
Anyone with access to the app object has access to its public properties. But are you giving that second app access to that first app object?
As a non-app example, I'll create a variable R. Don't worry too much about the details of what it is. What's important is that it's an object.
R = RandStream.create('mt19937ar');
It has properties that I can get since I have access to the object.
p = properties(R)
S = R.Seed
But if I call a function and don't give it the object, it can't ask for properties of the object even though they're public. It has no idea what R is, even though it exists in the calling workspace. It didn't get passed into the myfun workspace.
myfun() % will error, doesn't know what R is
function myfun
disp("Inside function myfun, trying to get the Seed property from R")
y = R.Seed; % will error
end
That documentation page I linked to gives some guidance about how to make the first app object accessible to the second app.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!