Objects in PHP are references by default. You do not need to implicitly use the pass by reference operator, nor should you. Also, with non-objects PHP performs copy on edit at an engine level, so the memory impact isn't there.
More on references.
PHP: References Explained - Manual
And, to be blunt, if you are having difficulty with a foreach iteration I sincerely doubt you have a technical reason for it.
In the code I gave you a way to test to see if you where getting what you expect - an array of objects. You need to test for that before iterating or the warning will pop up. Joomla doesn't exactly have the most consistent API out there (neither does core PHP for that matter), so I'm guessing the function is returning boolean "false" to alert you that there are no objects found. You can't iterate over "false" so foreach emits a warning.
So check and see what the function is actually returning.