Copyright law applies to code. Patents apply to inventions or methods. Put another way, the code itself cannot be patented, but what the code does may be able to be patented.
That's really what Apple is arguing (and I'm not defending Apple here). They claim that the patented methods they have created (e.g. swipe to unlock, etc.) have been infringed upon by Samsung. In patent litigation like this, the question usually comes down to what's known as "prior art", that is, the method or invention existed prior to the patent holder's supposed invention. I'm sure Samsung has lawyers crawling through data to find evidence of prior art for Apple's inventions in question.
Keep Up with TechRepublic