First, make sure you use an apple variety that holds up well to cooking. There is a list in this post to help you pick. Second, be sure to cook the apple slices with the sugar. Adding it before the cooking process will help the apples hold their shape better.