It's really frustrating when you buy a great yarn for a project only to find that the yarn sheds either while you are knitting or when you wear or use the project.
There's not a lot to do about a sheddy yarn when you're knitting, but there are some things you can try to eliminate yarn shedding in finished knit projects.
Generally speaking, yarn sheds because there is not enough twist in the yarn to hold all of the fibers together. It's a common problem with chenille and similarly produced yarns, which have a pile worked around a core yarn, but it can happen with other fibers as well, particularly those fuzzy fibers like angora and mohair.
Yarn that sheds while you're knitting is really frustrating, but it's difficult to deal with the problem in the middle of a project. One thing you can do to make it less annoying is to cover your lap with a cloth when you work on the project, so at least you're not getting fiber all over yourself.
Once the knitting is done, the best way to combat shedding yarn is to wash the project in whatever way the yarn requires (that's usually hand washing in a gentle detergent, letting the garment soak for 15 minutes or so), getting as much of the water out as you can and allowing the project to tumble dry on the air dry setting of your dryer for at least 10 or 15 minutes (though one post I read about eliminating shedding said it took almost two hours for a mohair project to stop shedding).
You might want to put the project in a zip-top pillowcase when you do this if you can, so that the shed fibers can be contained, or clean out your lint trap regularly if the process takes longer than 10 or 15 minutes.