Core Data objects correspond to instances of NSManagedObject or a subclass of NSManagedObject , so you cannot just save URL requests directly. What you can do is create an object called SavedRequest that has a property that represents the request for the URL, and maybe some other details about the request (what other information do you need - date, maybe?).
Since NSURLRequest conforms to NSCoding , you must create this property using the Transformable Core Data type. Core Data will use NSCoding to automatically convert to / from NSData as needed. You assigned the NSURLRequest property to the property and read them back, and Core Data would save them as NSData .
Given your description, Core Data may not make sense. It looks like you just want to save a list of URL requests and then read it and don't need the extra features provided by Core Data. It would be easier to place NSURLRequest objects in an array, and then save that array to a file or by default for the user. You convert to / from NSData yourself, but since you can easily use NSCoding .
To save the array, you would do something like this, assuming an array called myArray contains URL requests and a path in filePath :
BOOL success = [NSKeyedArchiver archiveRootObject:myArray toFile:filePath];
You will get the array back using
NSArray *savedRequests = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
source share