Error [__NSArrayM length]: unrecognized selector sent to instance


Here’s my script

tell application "System Events"
         set numberOfFiles2 to (number of files in folder theFolder) as integer
end tell
        set report to numberOfFiles2 & " files copied of 10"
        log report
        textView's setString_(report)

All goes well, apart from the line textView’s setString_(report). In the log I get the error 2014-08-07 19:53:47.303 Prova[1600:303] -[__NSArrayM length]: unrecognized selector sent to instance 0x61000004d7d0.
It seems like an illegal form of numberOfFiles2, but if I log it, just returns the number of the files.
How can I fix?

So report will be a list: {numberOfFiles2, " files copied of 10"}. Your “as integer” should be “as text”.

But even if I write textView’s setString_(numberOfFiles2) it gives me the same error…

And will keep doing it, until you stop trying to pass an integer when it requires a string.

Ok resolved :wink: