Log statement suppresses error?

While messing around with the file searching problem just posted by Budgie, I wrote the following program to do a deep search for specific files. If I comment out the “log fullPath” line, I get the following in the console:

property parent : class "NSObject"
	property theFolder : POSIX path of (path to documents folder as string)
	on applicationWillFinishLaunching_(aNotification)
		set theEnumerator to current application's NSFileManager's defaultManager()'s enumeratorAtPath_(theFolder)
		set nameArray to current application's NSMutableArray's alloc()'s init()
			set fullPath to theEnumerator's nextObject()
			--log fullPath
			if fullPath is missing value then exit repeat
			set ext to fullPath's pathExtension()
			set theName to fullPath's stringByDeletingPathExtension()'s lastPathComponent()
			if (ext's isEqualToString_("plist") as integer is 1) and (theName's hasPrefix_("July") as integer is 1) then
				nameArray's addObject_(theName)
			end if
		end repeat
		log nameArray
	end applicationWillFinishLaunching_

About 16 blinds up from the bottom, I see the results I was expecting, but then the app crashes.

However, if I uncomment out the “log fullPath” line, the program runs normally.

To further complicate things, sometimes I get a shorter list of errors (of the same type I see above) with no results and a crash (with the log statement commented out).

Am I doing something wrong here, or is this a bug?


Using ARC instead of garbage collection?

I have no idea what ARC is, so I hope I’m not using it. I had garbage collection on when i was using SL, now I’m on Lion but still using Xcode 3 (I don’t remember where to check that it’s on)


Project → Edit Active Target. (ARC is auto-reference counting, a sort of mid-way between garbage collection and normal reference counting.)

Garbage collection is set to Required [-fobjc-gc-only]

One thing I forgot to mention is that if I search in “/Users/rdelmar/Documents/Weather/” (which is where the files are that I’m testing for), it works fine without the log statement. It’s when I start the search at “/Users/rdelmar/Documents/” that I get all the errors.


I get the same error here. Looks like there’s a memory bug in the class returned by enumeratorAtPath_ (NSPathStore2).

Odd that logging fixes it, presumably be keeping it alive a little longer…