Applescript to ApplescriptObjC

Hi I am trying to convert some applescript to ObjC and I run into the error listed below,

As far as I know the issue is the set tc to (count rtf)? But not sure how to handle it?

set aFolder to (choose folder with prompt "Select Folder containing brands")
set UploadPath to (aFolder as string)

tell application "Finder" to set dtF to get name of folders of folder (UploadPath)
set tc to (count dtF)
repeat with i from 1 to tc
	--do something
end repeat

2014-06-17 16:49:32.931 Uploader[20356:303] *** -[AppDelegate ProcessAll:]: Finder got an error: Can’t make «class ocid» id «data optr00000000B063280000600000» into type integer. (error -1700)

Hi,

although the code is not ObjC at all nor AppleScriptObjC :wink: it should work.

This kind of error message normally indicates that AppleScript tries to access a Cocoa object which needs some coercion

Is it as easy as adding the as text?
Currently appears to stop the error

 tell application "Finder" to set dtF to get name of folders of folder (UploadPath as text)