WebScriptObject "life of a" script problem

Discussion in 'Mac Programming' started by Bunkum, Mar 18, 2012.

  1. Bunkum, Mar 18, 2012
    Last edited: Mar 19, 2012

    Bunkum macrumors newbie

    Jun 4, 2010
    So I've run into a little problem and I'm not sure if I'm doing something wrong or if it's actually designed like this, and so I'm not using it how it was meant to be used.

    When I evaluate a script or add global functions/function callbacks (and they are set with kJSPropertyAttributeDontDelete and kJSPropertyAttributeReadOnly), and then wish to make use of it repeatedly later using callWebScriptMethod:withArguments: it only seems to last for certain number of calls before they (I assume) get freed. Now if I call a global function callback they stay around for a quite a bit longer but still eventually get freed.

    Now a number of the WebScriptObject's private method still report as if it was working properly, it's only when it tries to execute it, it returns undefined and the actions in the script are not performed (reason I think it's getting freed).

    So is there a way/something I'm missing in order to get the scripts and functions to last for the life of the WebScriptObject?

    EDIT: Actually I realized it is because I'm not setting the evaluated scripts as kJSPropertyAttributeDontDelete, since the global functions and callbacks I used and did set with it still function. However I don't know how I'm meant to go about setting the properties of the evaluated scripts.

    EDIT: I've got one way I can go about it but it doesn't seem like the correct solution. Get all the properties for that WebScriptObject object. But the problem with this is it obviously has all the properties (don't want to modify all of them), I only want the properties from the script that was evaluated.

Share This Page