저는 iOS를 처음 접했습니다. 저는 Core Data를 완전히 처음 사용합니다. 저는 교수님의 전 대학원생들로부터 프로젝트의 코드베이스를 인수하고 있습니다.
내 앱이 데이터베이스에서 이미지를 가져올 때 img의 경로는 다음과 같습니다.
/Users/matt/Library/Developer/CoreSimulator/Devices/DA58E774-84BE-48F6-B50F-5921F682E87B/data/Containers/Bundle/Application/DA30DEFB-D90B-4D52-8462-3F8A5F4C55ED/Leaflet-US.app/thumbnail/species/Abies fraseri/images/LTV-BAM-2848_crop.jpg
CoreSimulator/Devices
이 경로에 포함되어 있기 때문에 앱의 Core Data에서 이미지를 찾는다고 가정합니다. 제가 실수 할 수 있으니 제가 틀렸다면 정정 해주세요.
또한 내 앱의 리소스 파일에 썸네일 버전이 있는데, 여기에는 Abies fraseri
디렉토리 가 포함되어 있습니다 .
Right now, the Core Data does not have the Abies fraseri
directory. I know this because in terminal I can cd
into /Users/matt/Library/Developer/CoreSimulator/Devices/DA58E774-84BE-48F6-B50F-5921F682E87B/data/Containers/Bundle/Application/DA30DEFB-D90B-4D52-8462-3F8A5F4C55ED/Leaflet-US.app/thumbnail/species/
and verify that Abies fraseri
does not exist. I would like to update the core data's version of thumbnail/species
so that it has it.
From what I've seen in these posts, you update an object of core data by adding specific key/value pair to the array that results from a fetch.
Example:
NSManagedObject *entityNameObj = [NSEntityDescription insertNewObjectForEntityForName:@"EntityName" inManagedObjectContext:context];
[entityNameObj setValue:@"someValue" forKey:@"someKey"];
However, is there a way to delete and re-enter thumbnail, rather than have to go through and specify each new key value pairs? I ask because I updated the local db, thumbnail, with 200 new species, each of which is a directory with several images.
The fetch request, if it applies:
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSManagedObjectContext* context = [(LeafletAppDelegate*)[[UIApplication sharedApplication] delegate] managedObjectContext];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Species" inManagedObjectContext:context] ;
[fetchRequest setEntity:entity];
if (predicate)
{
[fetchRequest setPredicate:predicate];
}
[fetchRequest setSortDescriptors:sortDescriptors];
// Create and initialize the fetch results controller.
NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:context sectionNameKeyPath:sectionNameKeyPath cacheName:nil];
self.fetchedResultsController = aFetchedResultsController;
fetchedResultsController.delegate = self;
// Memory management.
[aFetchedResultsController release];
[fetchRequest release];
return fetchedResultsController;
Because CoreSimulator/Devices is included in the path, I assume it looks for the image in the app's Core Data. I could be mistake, so please correct me if I'm wrong.
You're mistaken. Nothing goes into Core Data unless you make specific Core Data calls to save the data there. "CoreSimulator" in the path means that you're looking at files used by the simulator and has nothing at all to do with whether you're using Core Data. As a result-- the parts of your code about doing fetch requests are not useful, unless you also have other code that saves to Core Data that you haven't mentioned. You haven't put anything in Core Data, therefore there's nothing to fetch.
I also have a version of thumbnail in my app's Resources file, which you can see does contain the Abies fraseri directory.
We actually can't. What that screenshot shows is that it's present in the Xcode project. That doesn't necessarily mean it's included in the app when you build it. It's possible to have files in the project that aren't part of the build. There are various reasons for that, including projects that have multiple targets that don't include all of the same files (for example an app and an app extension).
But it's also possible to leave files out of a target by accident, and that's a likely cause of your problem. Select the images in question and open up Xcode's file inspector on the right side of the window. Look in the "target membership" section and make sure there's a check mark next to the app target.
가능성은 적지 만 불가능하지는 않은 또 다른 가능성은 잘못된 위치를 찾고 있다는 것입니다. Xcode는 서로 독립적 인 다양한 시뮬레이터를 지원합니다. 하나의 시뮬레이터에 대해 빌드하고 있지만 다른 시뮬레이터의 파일 경로를 확인하는 것이 가능합니다. 예를 들어, iPhone 7 시뮬레이터 용으로 빌드하고 있지만 iPhone SE 시뮬레이터 용 파일 경로를보고있을 수 있습니다. 파일은 공유되지 않으므로 하나를 업데이트해도 다른 파일에는 영향을주지 않습니다.
실제 원인에 관계없이 문제가 파일 관리 중 하나로 발생하고 코어 데이터와 관련이없는 것으로 보입니다. 언급하거나 공유하지 않은 코어 데이터에 기록하는 다른 코드가없는 경우에도 마찬가지입니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다