Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would recommend you that you use the Magical Record framework (<a href="https://github.com/magicalpanda/magicalrecord" rel="nofollow">https://github.com/magicalpanda/magicalrecord</a>), it makes too much easier Core Data management! </p> <p>In the other hand if you want keep on without it I will try changing:</p> <pre><code> + (Project *)createProjectWithDictionary:(NSDictionary *)dic inManagedObjectContext:(NSManagedObjectContext *)managedObjectContext { Project *project = nil; // Build a fetch request to see if we can find this Flickr photo in the database. // The "unique" attribute in Photo is Flickr's "id" which is guaranteed by Flickr to be unique. NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"Project"]; request.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"title" ascending:YES]]; request.predicate = [NSPredicate predicateWithFormat:@"title = %@", [dic[kTagProjectTitle]description]]; // Execute the fetch NSError *error = nil; NSArray *matches = [managedObjectContext executeFetchRequest:request error:&amp;error]; // Check what happened in the fetch if (!matches || ([matches count] &gt; 1)) { // nil means fetch failed; more than one impossible (unique!) // handle error } else if (![matches count]) { // none found, so let's create a Photo for that Flickr photo project = [matches lastObject]; NSLog(@"Encontrado Primera vez"); //Makes that only if you want to rehydrate your saved object. At other way I am not sure what yo want to do here :S project.projectId = [NSNumber numberWithInt:[[dic valueForKey:kTagProjectId] intValue]]; project.title = [dic valueForKey:kTagProjectTitle]; project.estimatedPrice = [NSNumber numberWithInt:[[dic valueForKey:kTagProjectEstimatedPrice] floatValue]]; NSMutableArray *tags = [[NSMutableArray alloc] init]; tags = [dic objectForKey:kTagProjectsTags]; for (NSDictionary * tagDic in tags){ NSString *tagName = [tagDic objectForKey:kTagProjectTagName]; Tag *tag = [NSEntityDescription insertNewObjectForEntityForName:@"Tag" inManagedObjectContext:managedObjectContext]; //TODO: populate tag object using tagDic [project addTagsObject:tag]; } </code></pre> <p>And remember to make the fetch in the same context if you haven't saved the current context ;)</p>
    singulars
    1. This table or related slice is empty.
    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.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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