Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Object Identity Tests in Core Data




On Aug 31, 2005, at 2:10 AM, Niko Matsakis wrote:

I guess it's that I didn't find documentation on what kinds of types are available in predicates.
<http://developer.apple.com/documentation/Cocoa/Conceptual/ CoreData/Articles/cdFetching.html#//apple_ref/doc/uid/TP40002484/ DontLinkElementID_18>
Yes, I read this before I posted, and also the Predicate Programming Guide. To be honest, the section here on comparing to self left me more confused then when I started.
What really confused me was this line in the code example under Retrieving Specific objects:


NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self == %@", targetObject];
In case anyone cares, this is what went though my head after reading this:
1. Okay, does this mean there is a special property called "self" on every managed object?

<http://developer.apple.com/documentation/Cocoa/Conceptual/Predicates/ Articles/pSyntax.html#//apple_ref/doc/uid/TP40001795-215930>


"SELF
Represents the object being evaluated."

2. I was confused because I didn't know what type targetObject was. If it's an NSManagedObject*, which makes sense, then why are you doing the fetch? You already have the answer!

To make sure that the object is accessible from the specified context.

3. Why is it using string substitution?

It's not string substitution:
<http://developer.apple.com/documentation/Cocoa/Conceptual/Predicates/ Articles/pSyntax.html#//apple_ref/doc/uid/TP40001795/ DontLinkElementID_6>
"The format string supports printf-style format arguments such as %x (see Formatting String Objects)). Two important arguments are %@ and %K.


%@ is a var arg substitution for a value (usually a string value)."

4. Then it mentions the IN operator, but doesn't show an example.

<http://developer.apple.com/documentation/Cocoa/Conceptual/Predicates/ Articles/pUsing.html#//apple_ref/doc/uid/TP40001794-250111>

mmalc


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Object Identity Tests in Core Data (From: Niko Matsakis <email@hidden>)
 >Re: Object Identity Tests in Core Data (From: Chris Hanson <email@hidden>)
 >Re: Object Identity Tests in Core Data (From: Niko Matsakis <email@hidden>)
 >Re: Object Identity Tests in Core Data (From: mmalcolm crawford <email@hidden>)
 >Re: Object Identity Tests in Core Data (From: Niko Matsakis <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.