Note that there are some explanatory texts on larger screens.

plurals
  1. POCore Data: why I can't fetch anything with my predicate
    primarykey
    data
    text
    <p>Is there something wrong with the code? I can fetch nothing using this predicate. Comment out the predicate then I can fetch all objects from entity "BankDetail". So I think problem resides in these two lines.</p> <pre><code>// self.bankInfo.name is set in prepareForSegue in first view controller NSPredicate *predicate = [NSPredicate predicateWithFormat:@"info.name = %@",self.bankInfo.name]; [request setPredicate:predicate]; </code></pre> <p>My model includes two entities, which are in one-to-one relationship</p> <p>BankInfo.h</p> <pre><code>@class BankDetail; @interface BankInfo : NSManagedObject @property (nonatomic, retain) NSString * city; @property (nonatomic, retain) NSString * name; @property (nonatomic, retain) NSString * state; @property (nonatomic, retain) BankDetail * detail; @end </code></pre> <p>BankDetail.h</p> <pre><code>@class BankInfo; @interface BankDetail : NSManagedObject @property (nonatomic, retain) NSString * closeDate; @property (nonatomic, retain) NSString * updateDate; @property (nonatomic, retain) NSString * zip; @property (nonatomic, retain) NSString * acquiringInstitution; @property (nonatomic, retain) BankInfo * info; @end </code></pre> <p><strong>EDIT:</strong></p> <p>To provide more detail:</p> <ul> <li><p><code>self.bankInfo.name</code> is definitely set, I NSLog it right before the line of predicate</p></li> <li><p>And I do this in <code>viewDidLoad</code>:</p> <pre><code>NSEntityDescription *entity = [NSEntityDescription entityForName:@"BankDetail" inManagedObjectContext:context]; NSLog(@"[entity description] is %@",[entity description]); </code></pre></li> </ul> <p>Get this in console:</p> <pre><code>info = "(&lt;NSRelationshipDescription: 0x6d3eb30&gt;), name info, isOptional 1, isTransient 0, entity BankDetail, renamingIdentifier info, validation predicates (\n), warnings (\n), versionHashModifier (null)\n userInfo {\n}, destination entity BankInfo, inverseRelationship detail, minCount 1, maxCount 1, isOrdered 0, deleteRule 2"; </code></pre> <p><strong>EDIT2:</strong> Turn out there's <strong>nothing wrong with the predicate</strong>. The bug is caused by a careless mistake elsewhere (see the accepted answer, it's about renaming). Please IGNORE this post if you have question about predicate.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload