• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Saving NSManagedObject in Core-Data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Saving NSManagedObject in Core-Data


  • Subject: Saving NSManagedObject in Core-Data
  • From: malcom <email@hidden>
  • Date: Tue, 1 Apr 2008 02:03:12 +0200

Hello to all!
What's the correct way in Core Data to save a stream of data?
This is the problem.
Suppose to have lots of packets each of these can be linked to a
parent and could have one or more childrens.
You can receive these packets ordered (so you can receive the parent
of message only in a message after x (the next or after other y
messages)).

The problem is to save these messages in CoreData without using lots
of CPU resources and your code need to "see" newly inserted messages.
I've made some tests with a a code of mine but it does not works.
Anyone can tell me what's the right way?
This is what I've made (suppose you receive a data from a multithreaded socket).

1) You receive the packet
2) Put it into a temp array
3) When you reach a number x of messages you can call the save function

The save function repeats these statements for each packet from the array:
1) Perform insertObject in a second managedObject (connected to the
same persistent store)
2) Get the list of objectID of the object and save it to another array
3) When all packets was saved perform linkMessages function into main
thread passing the objectids array

The LinkMessages function:
1) Perform a refreshObject: elementOfTheArray mergeChanges: YES for
each object passed by the array
2) Find the parent/childs and make the right releationships
3) Perform a save operation to disk

I think it could be correct but it does not work because the newly
insert objects seems to be invisible into the main context. Where I'm
wrong?
I'm going crazy with this damn thing :(
Thanks a lot for each response!
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: window stay on top
  • Next by Date: Re: Simple menu-action question
  • Previous by thread: Re: window stay on top
  • Next by thread: Custom interface
  • Index(es):
    • Date
    • Thread