How to auto-increment reference number persistently when NSManagedObjects created in core-data.

Posted by KayKay on Stack Overflow See other posts from Stack Overflow or by KayKay
Published on 2010-06-09T12:19:09Z Indexed on 2010/06/11 0:03 UTC
Read the original article Hit count: 327

In my application i am using core-data to store information and saving these data to the server using web-connectivity i have to use MySql.
Basically what i want to do is to keep track of number of NSManagedObject already created and Whenever i am adding new NSManagedObject, based on that counting it will assign the class a Int_value which will act as primary_key in MySql.
For examaple, there are already 10 NSManagedobjects, and when i will add new one it will assign it "11" as primary_key. these value will have to be increasing because there is no deleting of NSManagedObject. From my approach its about static member in applicationDelegate whose initial value can be any integer but should be incremented by one(like auto-increment) everytime new NSManagedObject is created and also it should be persistent. I am not clear how to do this, please give me suggestions. Thanks in advance.

© Stack Overflow or respective owner

Related posts about iphone-sdk-3.0

Related posts about core-data