Note that there are some explanatory texts on larger screens.

plurals
  1. POCore data do not fetch record
    primarykey
    data
    text
    <p>i added website field in core data after adding other attributes to xcdatamodel, and i am saving this attribute like this</p> <pre><code>- (void)fetchandSaveGWTGsSince:(NSString *)since { NSString *completeURL = [NSString stringWithFormat:@"%@api.php?action=get_all_gwtgs&amp;sinceDate=%@", BASE_URL, since]; NSURL *url = [NSURL URLWithString:completeURL]; // self.loggingEnable = NO; if (self.loggingEnable == YES) { NSLog(@"%@", [NSString stringWithFormat:@"%i", [since integerValue]-18000]); NSLog(@"%@", since); NSLog(@"%@", [[NSDate dateWithTimeIntervalSince1970:(NSTimeInterval)[since integerValue]] description]); NSLog(@"%@", [[NSDate dateWithTimeIntervalSince1970:((NSTimeInterval)[since integerValue])-18000] description]); NSLog(@"%@", completeURL); } NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; request.timeoutInterval = REQUEST_TIMEOUT; [AFJSONRequestOperation addAcceptableContentTypes:[NSSet setWithObject:@"text/html"]]; AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { NSDictionary *resDict = (NSDictionary *)JSON; if (self.loggingEnable == YES) { NSLog(@"Response GWTGs : %@", resDict); } if ([[resDict objectForKey:@"status"] isEqualToString:@"success"]) { NSArray *data = [[resDict objectForKey:@"data"] objectAtIndex:0]; NSManagedObjectContext *context = [[Common apd] managedObjectContext]; if ([data count] &gt; 0) { [data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { NSDictionary *gwtgDict = (NSDictionary *)obj; if ([gwtgDict objectForKey:@"gwtg_id"]) { NSArray *locationInfos = [self getGWTGsWithGWTG_ID:[gwtgDict objectForKey:@"gwtg_id"]]; if ([locationInfos count] &gt; 0) { for (Location *location in locationInfos) { [context deleteObject:location]; NSError *error = nil; if (![context save:&amp;error]) { // Handle the error. if (self.loggingEnable == YES) { NSLog(@"error deleting gwtg : %@", [location description]); } } } } } }]; } [data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { NSDictionary *gwtgInfo = (NSDictionary *)obj; /* gwtg_status = 0 =&gt; Inactive Record gwtg_status = 1 =&gt; New Record/Active Record gwtg_status = 2 =&gt; Updated Record gwtg_status = 3 =&gt; Deleted Record */ if ([[gwtgInfo objectForKey:@"gwtg_status"] intValue] != 3) { GWTG *gwtg = [NSEntityDescription insertNewObjectForEntityForName:@"GWTG" inManagedObjectContext:context]; gwtg.gwtg_id = ([[gwtgInfo objectForKey:@"gwtg_id"] isKindOfClass:[NSNull class]]) ? @"" : [gwtgInfo objectForKey:@"gwtg_id"]; NSData *celData = [NSData dataWithBase64EncodedString:[gwtgInfo objectForKey:@"celebrity_name"]]; NSString *celName = [[NSString alloc] initWithData:celData encoding:NSStringEncodingConversionAllowLossy]; gwtg.celebrity_name = ([celName isKindOfClass:[NSNull class]]) ? @"" : celName; gwtg.location_id = ([[gwtgInfo objectForKey:@"location_id"] isKindOfClass:[NSNull class]]) ? @"" : [gwtgInfo objectForKey:@"location_id"]; NSData *loc_cityData = [NSData dataWithBase64EncodedString:[gwtgInfo objectForKey:@"location_city"]]; NSString *loc_cityName = [[NSString alloc] initWithData:loc_cityData encoding:NSStringEncodingConversionAllowLossy]; gwtg.location_city = ([loc_cityName isKindOfClass:[NSNull class]]) ? @"" : loc_cityName; NSData *cityData = [NSData dataWithBase64EncodedString:[gwtgInfo objectForKey:@"city"]]; NSString *cityName = [[NSString alloc] initWithData:cityData encoding:NSStringEncodingConversionAllowLossy]; gwtg.city = ([cityName isKindOfClass:[NSNull class]]) ? @"" : cityName; NSData *stateData = [NSData dataWithBase64EncodedString:[gwtgInfo objectForKey:@"state"]]; NSString *stateName = [[NSString alloc] initWithData:stateData encoding:NSStringEncodingConversionAllowLossy]; gwtg.state = ([stateName isKindOfClass:[NSNull class]]) ? @"" : stateName; NSData *countryData = [NSData dataWithBase64EncodedString:[gwtgInfo objectForKey:@"country"]]; NSString *countryName = [[NSString alloc] initWithData:countryData encoding:NSStringEncodingConversionAllowLossy]; gwtg.country = ([countryName isKindOfClass:[NSNull class]]) ? @"" : countryName; gwtg.a_consuming = ([[gwtgInfo objectForKey:@"a_consuming"] isKindOfClass:[NSNull class]]) ? @"" : [gwtgInfo objectForKey:@"a_consuming"]; gwtg.a_playing = ([[gwtgInfo objectForKey:@"a_playing"] isKindOfClass:[NSNull class]]) ? @"" : [gwtgInfo objectForKey:@"a_playing"]; gwtg.a_lodging = ([[gwtgInfo objectForKey:@"a_lodging"] isKindOfClass:[NSNull class]]) ? @"" : [gwtgInfo objectForKey:@"a_lodging"]; gwtg.a_shopping = ([[gwtgInfo objectForKey:@"a_shopping"] isKindOfClass:[NSNull class]]) ? @"" : [gwtgInfo objectForKey:@"a_shopping"]; gwtg.a_recommending = ([[gwtgInfo objectForKey:@"a_recommending"] isKindOfClass:[NSNull class]]) ? @"" : [gwtgInfo objectForKey:@"a_recommending"]; gwtg.w_g_here = ([[gwtgInfo objectForKey:@"w_g_here"] isKindOfClass:[NSNull class]]) ? @"" : [gwtgInfo objectForKey:@"w_g_here"]; NSData *locData = [NSData dataWithBase64EncodedString:[gwtgInfo objectForKey:@"location_name"]]; NSString *locName = [[NSString alloc] initWithData:locData encoding:NSStringEncodingConversionAllowLossy]; gwtg.location_name = ([locName isKindOfClass:[NSNull class]]) ? @"" : locName; //location_address, we_go_here, credit NSData *locAdData = [NSData dataWithBase64EncodedString:[gwtgInfo objectForKey:@"location_address"]]; NSString *locAdName = [[NSString alloc] initWithData:locAdData encoding:NSStringEncodingConversionAllowLossy]; gwtg.location_address = ([locAdName isKindOfClass:[NSNull class]]) ? @"" : locAdName; gwtg.location_phone = ([[gwtgInfo objectForKey:@"location_phone"] isKindOfClass:[NSNull class]]) ? @"" : [gwtgInfo objectForKey:@"location_phone"]; gwtg.location_zip_code = ([[gwtgInfo objectForKey:@"location_zip_code"] isKindOfClass:[NSNull class]]) ? @"" : [gwtgInfo objectForKey:@"location_zip_code"]; NSData *wghData = [NSData dataWithBase64EncodedString:[gwtgInfo objectForKey:@"we_go_here"]]; NSString *wghName = [[NSString alloc] initWithData:wghData encoding:NSStringEncodingConversionAllowLossy]; gwtg.we_go_here = ([wghName isKindOfClass:[NSNull class]]) ? @"" : wghName; gwtg.wgh_date = ([[gwtgInfo objectForKey:@"wgh_date"] isKindOfClass:[NSNull class]]) ? @"" : [gwtgInfo objectForKey:@"wgh_date"]; NSData *creData = [NSData dataWithBase64EncodedString:[gwtgInfo objectForKey:@"credit"]]; NSString *creName = [[NSString alloc] initWithData:creData encoding:NSStringEncodingConversionAllowLossy]; gwtg.credit = ([creName isKindOfClass:[NSNull class]]) ? @"" : creName; NSData *webSite_Data = [NSData dataWithBase64EncodedString:[gwtgInfo objectForKey:@"website"]]; NSString *add_website = [[NSString alloc] initWithData:webSite_Data encoding:NSStringEncodingConversionAllowLossy]; gwtg.website = ([add_website isKindOfClass:[NSNull class]]) ? @"" : add_website; gwtg.gwtg_status = ([[gwtgInfo objectForKey:@"gwtg_status"] isKindOfClass:[NSNull class]]) ? @"" : [gwtgInfo objectForKey:@"gwtg_status"]; gwtg.gwtg_isactive = ([[gwtgInfo objectForKey:@"gwtg_isactive"] isKindOfClass:[NSNull class]]) ? @"" : [gwtgInfo objectForKey:@"gwtg_isactive"]; gwtg.addeddate = ([[gwtgInfo objectForKey:@"addeddate"] isKindOfClass:[NSNull class]]) ? @"" : [gwtgInfo objectForKey:@"addeddate"]; gwtg.modifieddate = ([[gwtgInfo objectForKey:@"modifieddate"] isKindOfClass:[NSNull class]]) ? @"" : [gwtgInfo objectForKey:@"modifieddate"]; if (self.loggingEnable == YES) { NSLog(@"----Location----"); NSLog(@"%@", gwtg.gwtg_id); NSLog(@"%@", gwtg.celebrity_name); NSLog(@"%@", gwtg.location_id); NSLog(@"%@", gwtg.city); NSLog(@"%@", gwtg.state); NSLog(@"%@", gwtg.country); NSLog(@"%@", gwtg.a_consuming); NSLog(@"%@", gwtg.a_playing); NSLog(@"%@", gwtg.a_lodging); NSLog(@"%@", gwtg.a_shopping); NSLog(@"%@", gwtg.a_recommending); NSLog(@"%@", gwtg.w_g_here); NSLog(@"%@", gwtg.location_name); NSLog(@"%@", gwtg.location_address); NSLog(@"%@", gwtg.location_phone); NSLog(@"%@", gwtg.location_zip_code); NSLog(@"%@", gwtg.we_go_here); NSLog(@"%@", gwtg.wgh_date); NSLog(@"%@", gwtg.credit); NSLog(@"%@", gwtg.website); NSLog(@"%@", gwtg.gwtg_status); NSLog(@"%@", gwtg.addeddate); NSLog(@"%@", gwtg.modifieddate); NSLog(@"%@", gwtg.gwtg_isactive); } NSError *error; if (![context save:&amp;error]) { NSLog(@"Whoops, couldn't save: %@", [error localizedDescription]); } } }]; if ([[NSUserDefaults standardUserDefaults] objectForKey:LAST_TIME_GWTG_UPDATED]) { [[NSUserDefaults standardUserDefaults] removeObjectForKey:LAST_TIME_GWTG_UPDATED]; } NSDate *date = [NSDate date]; NSLog(@"date last time : %@", [data description]); [[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithFormat:@"%.f", [date timeIntervalSince1970]] forKey:LAST_TIME_GWTG_UPDATED]; [[NSUserDefaults standardUserDefaults] synchronize]; [[NSNotificationCenter defaultCenter] postNotificationName:kNotificationRequestFinished object:nil userInfo:nil]; } else { // [Common showAlertWithTitle:@"Warning" message:[resDict objectForKey:@"message"]]; if ([[NSUserDefaults standardUserDefaults] objectForKey:LAST_TIME_GWTG_UPDATED]) { } else { [[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithFormat:@"0"] forKey:LAST_TIME_GWTG_UPDATED]; [[NSUserDefaults standardUserDefaults] synchronize]; } } } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) { if (self.loggingEnable == YES) { NSLog(@"error %@", [error description]); } [Common showAlertWithTitle:@"Error Retrieving" message:[NSString stringWithFormat:@"%@",[error localizedDescription]]]; if ([[NSUserDefaults standardUserDefaults] objectForKey:LAST_TIME_GWTG_UPDATED]) { } else { [[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithFormat:@"0"] forKey:LAST_TIME_GWTG_UPDATED]; [[NSUserDefaults standardUserDefaults] synchronize]; } }]; [operation start]; } </code></pre> <p>and i am getting website url like this, but it always come empty, </p> <pre><code>NSString *urlString = [NSString stringWithFormat:@"%@", _gwtgDO.website]; NSURL *url = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; [[UIApplication sharedApplication] openURL:url]; </code></pre> <p>why it is always empty although i am getting website link from server correctly? is this due to reason that i added attribute later? what should i do now?</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.
    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