Sets don't understand lastObject.  Try to be generic and use objectEnumerator instead.