NSPredicate with CoreData SQL store behavior
NSPredicate with CoreData SQL store behavior
- Subject: NSPredicate with CoreData SQL store behavior
- From: Jesse Grosjean <email@hidden>
- Date: Wed, 15 Mar 2006 10:12:33 -0500
I have a few questions concerning NSPredicate and a CoreData SQL
store. I'm trying to get my assumptions strait, I though I knew this
stuff, but recently I've run into a couple of problems that I didn't
expect.
First at some point I "learned" that when fetching on a SQL type
store predicates would only return results from the entities that
were committed to the store. For example if I add a new entity it
would not show up in the fetch results until I saved the store. In my
head this makes sense since the predicate is implemented as an SQL
query. And this is also the behavior that I see in my application
that constructs its own core data stack.
But, I was just doing some tests with default NSPersitentDocument
based application and the above rule doesn't seem to hold. I create a
new document, saved as SQL type. Closed and then reopened the
document (to make sure that it was using the SQL store and not the
initial in memory store) and then I added a new entity and that
entity showed up in my fetches immediately without me needing to save
the document. Also if I made a modification to an existing attribute
that change would be reflected in the search results without me
needing to save.
Does anyone know why this would be? Is the NSPersitentDocument class
doing something special to allow fetches to see changes before they
are committed to the store, or was my original assumption wrong? I
would love to get this behavior into my own managed object stack that
doesn't use NSPersitentDocument.
My second question is what is the best way to do a "contains" search
on strings in the SQL store? I had been using seaches like
"myStringAttribute like[cd] '*searchstring*'", but I just found out
that that type of search seems to completely break (no results) if
myStringAttribute contains any newLine characters (return key). Is
that expected behavior? And if so what is the best way to find if a
string attribute (that might have new lines) contains another string?
Thanks for any pointers, my brains feeling a bit frazzled at the moment.
Jesse
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden