Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Having a problem with applescript object c app.

Hi,


Just wondering if anyone can help me with this.


I am building a little application in xcode that basically attempts to get certain images by a designated url and then displays them within the app in an image well. If the images do not exists at the assisgned URL then it will display a question mark. here is an exampole of the main bit of code it uses;





on applicationrunthatshit_(sender)



------ error image

try

set imageurlerror to("http://content.answcdn.com/main/content/img/getty/5/2/CC000552.jpg")

set theURLerror to current application's NSURL's URLWithString_(imageURLerror)

set theImageerror to current application's NSImage's alloc's initWithContentsOfURL_(theURLerror)

end try


------ SWATCH


try

set imageurl to ("http://static.guim.co.uk/sys-images/Technology/Pix/pictures/2012/8/8/13444203329 67/Google-basketball-008.jpg")

set theURL to current application's NSURL's URLWithString_(imageURL)

set theImage to current application's NSImage's alloc's initWithContentsOfURL_(theURL)

theImage's setSize_({50, 50})

swatch_preview's setImage_(theImage)

on error

swatch_preview's setImage_(theImageerror)

end try


------ UNDERSCORE 1


try

set imageurl to ("http://static.guim.co.uk/sys-images/Technology/Pix/pictures/2012/8/8/13444203329 67/Google-basketball-008.jpg")

set theURL to current application's NSURL's URLWithString_(imageURL)

set theImage to current application's NSImage's alloc's initWithContentsOfURL_(theURL)

theImage's setSize_({50, 75})

underscore1_default_l's setImage_(theImage)

on error

underscore1_default_l's setImage_(theImageerror)

end try


end applicationrunthatshit_



The problem I am having is that every couple of uses the app will crash and the error code in xcode is :

objc[7543]: Object 0x100506980 of class __NSCFString autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug


When it works it does exactly what I wanted it to do, but it comes up with this error about 50% of the time. I'm not expert with xcode so If anyone could point me in the right direction that would be great!


Thanks in advance,


Mark

xcode-OTHER, Mac OS X (10.7.5)

Posted on Nov 9, 2012 7:29 AM

Reply
Question marked as Best reply

Posted on Nov 9, 2012 7:58 AM

The memory management in AppleScriptObjC is automatic. An NSCFString is one of the private core structures, so that message (the string is just leaking, which is not fatal) is coming from someplace in the underlying frameworks.


If your application is crashing, you might try using the on error sections in your try statements to get the error results and log them - as it is, any actual errors are just thrown away.

3 replies
Question marked as Best reply

Nov 9, 2012 7:58 AM in response to Mark Ashton

The memory management in AppleScriptObjC is automatic. An NSCFString is one of the private core structures, so that message (the string is just leaking, which is not fatal) is coming from someplace in the underlying frameworks.


If your application is crashing, you might try using the on error sections in your try statements to get the error results and log them - as it is, any actual errors are just thrown away.

Nov 11, 2012 5:55 AM in response to red_menace

Thanks Red, I managed to find the problem and it came from when the image at the end of the URL didn't exist. This crashed the app when it tried to set an non existent image size.


I might need to ask a new question, it loops a lot of these different image changes but it doesn't update them until the end of the run. Is there a way to get the image to update whilst it is still running?


Thanks again

Having a problem with applescript object c app.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.