"El me dio unos dulces y yo a cambio le dí las gracias"
He gave me some sweets(candies) and I thanked him (gave him my thanks).
------------------------------
"El me dio unos dulces y yo acepte no sin antes darle las gracias"
He gave me some sweets(candies) and I took (accepted) them without first saying "thank you" (without first giving him my thanks).