Note that there are some explanatory texts on larger screens.

plurals
  1. POSaving and receiving URL not working
    text
    copied!<p>I am trying to save a URL for a video to core data. To do this I am creating a string containing the URL, saving it to core data, and then retrieving it in another view controller. When retrieving it in the other View Controller, I get this error: <code>Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initWithString:relativeToURL:]: nil string parameter'</code> I have worked out that the URL being saved contains the URL, but when receiving it, it is nill. How would I fix this.</p> <p>Here is the code to save the URL:</p> <pre><code>- (void) saveVideo { NSManagedObjectContext *context = [self managedObjectContext]; TimeTravelDetails *timeTravelDetails = [NSEntityDescription insertNewObjectForEntityForName:@"TimeTravelDetails" inManagedObjectContext:context]; NSString *stringForSave = [self.videoURL absoluteString]; NSLog(@"String being saved: %@", stringForSave); [timeTravelDetails setValue: stringForSave forKey:@"urlString"]; NSError *error = nil; if (![self.managedObjectContext save:&amp;error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); } else { NSLog(@"URL String saved"); NSLog(@"String being saved: %@", stringForSave); } //NSLog(@"%@", self.videoURL); } </code></pre> <p>Here is were I retrieve it:</p> <pre><code>- (void) getUrl { NSManagedObjectContext *context = [self managedObjectContext]; TimeTravelDetails *timeTravelDetails = [NSEntityDescription insertNewObjectForEntityForName:@"TimeTravelDetails" inManagedObjectContext:context]; NSString *stringForURL = [[NSString alloc] init]; stringForURL = timeTravelDetails.urlString; NSLog(@"The string has been recieved: %@", stringForURL); self.finalURL = [[NSURL alloc] initWithString:stringForURL]; } </code></pre>
 

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