问题
I have just updated to the new Xcode beta 6.0 and when trying to compile for an ipad mini with iOS 8 I am getting a weird error in the console:
"Attempt to add read-only file at path file:///var/mobile/Media/PhotoData/Photos.sqlite?readonly_shm=1 read/write. Adding it read-only instead. This will be a hard error in the future; you must specify the NSReadOnlyPersistentStoreOption"
This happens when executing the following code:
if ([self.rootDelegate respondsToSelector:@selector(wImageRequiresAPhotoPicker:)]){
[self.rootDelegate wImageRequiresAPhotoPicker:(DWImage*)item];
}
And:
-(void)wImageRequiresAPhotoPicker:(DWImage *)img{
self.selectedWimg = img;
DWImagePickerController *imgPicker = [[DWImagePickerController alloc] init];
[imgPicker setDelegate:self];
[imgPicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[imgPicker setAllowsEditing:YES];
[imgPicker setModalPresentationStyle:UIModalPresentationCurrentContext];
UIPopoverController *popOver = [[UIPopoverController alloc] initWithContentViewController:imgPicker];
popOver.delegate = self;
self.popoverImageViewController = popOver;
[self.popoverImageViewController presentPopoverFromRect:img.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
Does anyone have a clue of why this is happening?
回答1:
Most likely a newly introduced bug in iOS 8 beta 2. Let's see how it develops.
It seems that ALAssetsLibrary requests internally read & write access to Photos.sqlite
database, and it can only gain read access. I'm receiving the same error with this call:
[self.assetsLibrary enumerateGroupsWithTypes:ALAssetsGroupAll
usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
...
回答2:
It is a core data error, and since my app does not use core data, and I receive the error when I access the photo library picker, I'm gonna say it is on Apple, and a bug. Apparently files are attempting to be added as read/write and they are read only. I'm pretty sure Apple should know this, since they set up the image picker. I'm just trying to access it.
self.pickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
来源:https://stackoverflow.com/questions/24370358/attempt-to-add-read-only-file-at-path-file-var-mobile-media-photodata-photos