Search code examples
mysqlioscalayerobject-properties

How to save ios object or view parameters to server?


What is the best way to save object parameters to DB in ios? => like sending values to server application and server will save the parameters to db? And later that ios-app will get the properties and create the new object again.

What is the best way to do it? For ex, saving CALayer or UIImageView attributes like size, position, color, border width etc..


Solution

  • You have to create a data model which defines what this data looks like.

    Once you have it, you will need to define some sort of REST api against your server to get/post/put/delete this data. To implement this network layer you can look at:

    https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/URLLoadingSystem/Articles/UsingNSURLSession.html

    AFNetworking and RestKit are other useful libs to consider

    To store locally you can look at CoreData - https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreData/cdProgrammingGuide.html