How would you release the memory taken by the previous image in an image view? In ASS I used something like:
set oldImage toimage of image view “myImageView” of window of theObject
delete oldImage
I have a pop up button and an image view on a window and three images on my desktop. When I run this code my app grows 4 mb every time I select an item from the pop up button.
script testImageProjectAppDelegate
property parent : class "NSObject"
property NSImage : class "NSImage" of current application
property popUpButton : missing value
property ImageView : missing value
on popUpButtonClicked_(sender)
set selectedImage to (popUpButton's titleOfSelectedItem(sender) as string)
set pathToImage to POSIX path of ((path to desktop as string) & selectedImage)
set showImage to NSImage's alloc()'s initWithContentsOfFile_(pathToImage)
ImageView's setImage_(showImage)
end popUpButtonClicked_
on applicationWillFinishLaunching_(aNotification)
-- Insert code here to initialize your application before any files are opened
end applicationWillFinishLaunching_
on applicationShouldTerminate_(sender)
-- Insert code here to do any housekeeping before your application quits
return true
end applicationShouldTerminate_
end script