Chapter 9 of LEGO MINDSTORMS NXT One-Kit Wonders will teach you how to build and program a robot that can find and grab objects. Using the Ultrasonic Sensor, GrabBot spins around looking for the closest object, moves toward it, rescans for a more precise location, then grabs and lifts the object.
The unique physical aspect of this robot is the grabber, which controls two functions with a single motor: grabbing and lifting. A Touch Sensor is used to detect if the grabber is lifted all the way up.
Building and programming instructions are in the book, but you can also download the program here.