특정 데이터를 추가하는 대신 전체 핵심 데이터 개체 다시로드

매디

저는 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;
Tom Harrington

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] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

상위 엔터티에 개체를 추가 할 때 중복을 만드는 핵심 데이터 대 다 관계

분류에서Dev

iOS : 일대 다 관계가있는 핵심 데이터 업데이트 개체

분류에서Dev

새로운 핵심 데이터 xcode 8.3 메서드 대신 앱 위임 이전 핵심 데이터 메서드를 대체 할 수 있습니까?

분류에서Dev

핵심 데이터-대다 관계에서 개체 순서

분류에서Dev

타사 개체를 핵심 데이터 개체로 사용

분류에서Dev

신속한 핵심 데이터는 일대 다 관계에서 객체를 얻습니다.

분류에서Dev

핵심 데이터가 빈 개체를 가져 오는 것 같습니다.

분류에서Dev

핵심 데이터, 관리 대상 개체를 효과적으로 찾고 삭제할 수있는 방법

분류에서Dev

핵심 데이터 개체를 TableView로 가져 오려고 할 때 'NSInvalidArgumentException'발생

분류에서Dev

핵심 데이터는 항상 첫 번째 개체를 삭제합니다.

분류에서Dev

핵심 데이터는 개체를 덮어 쓰지 않습니다.

분류에서Dev

핵심 데이터 개체에서 개체를 가져 오면 잘못된 개체가 검색됩니다.

분류에서Dev

핵심 데이터가있는 경우 기존 개체를 업데이트합니다.

분류에서Dev

검색된 핵심 데이터 개체로 작업하는 방법

분류에서Dev

핵심 데이터 : 개체 삭제 / 추가 오류

분류에서Dev

일대 다 관계 핵심 데이터는 마지막 개체 만 저장합니다. 기타 누락

분류에서Dev

속성 값이 정의 된 핵심 데이터 개체 수

분류에서Dev

하나의 관리 개체로 핵심 데이터 미리 채우기

분류에서Dev

이진 데이터 개체를 핵심 데이터 엔터티로 마이그레이션

분류에서Dev

다른 tableView 섹션의 핵심 데이터 개체

분류에서Dev

핵심 데이터 개체의 관계에 할당하면 개체가 손상된 것 같습니다.

분류에서Dev

SQL 쿼리를 핵심 데이터 가져 오기 요청으로 교체

분류에서Dev

핵심 데이터에서 이미지를로드하면 NavigationView 전환이 불안정 해집니다.

분류에서Dev

많은 값을 포함하는 핵심 데이터 개체 업데이트

분류에서Dev

핵심 데이터 개체 변경에 대한 SwiftUI 업데이트보기

분류에서Dev

핵심 데이터에서 기존 개체와의 관계를 만드는 방법

분류에서Dev

핵심 데이터는 목록 항목에 포함 된 개체를 찾습니다.

분류에서Dev

핵심 데이터를 객체로 읽기

분류에서Dev

핵심 데이터는 관리되는 개체를 저장하지만 데이터는 앱 실행 사이에 유지되지 않습니다.

Related 관련 기사

  1. 1

    상위 엔터티에 개체를 추가 할 때 중복을 만드는 핵심 데이터 대 다 관계

  2. 2

    iOS : 일대 다 관계가있는 핵심 데이터 업데이트 개체

  3. 3

    새로운 핵심 데이터 xcode 8.3 메서드 대신 앱 위임 이전 핵심 데이터 메서드를 대체 할 수 있습니까?

  4. 4

    핵심 데이터-대다 관계에서 개체 순서

  5. 5

    타사 개체를 핵심 데이터 개체로 사용

  6. 6

    신속한 핵심 데이터는 일대 다 관계에서 객체를 얻습니다.

  7. 7

    핵심 데이터가 빈 개체를 가져 오는 것 같습니다.

  8. 8

    핵심 데이터, 관리 대상 개체를 효과적으로 찾고 삭제할 수있는 방법

  9. 9

    핵심 데이터 개체를 TableView로 가져 오려고 할 때 'NSInvalidArgumentException'발생

  10. 10

    핵심 데이터는 항상 첫 번째 개체를 삭제합니다.

  11. 11

    핵심 데이터는 개체를 덮어 쓰지 않습니다.

  12. 12

    핵심 데이터 개체에서 개체를 가져 오면 잘못된 개체가 검색됩니다.

  13. 13

    핵심 데이터가있는 경우 기존 개체를 업데이트합니다.

  14. 14

    검색된 핵심 데이터 개체로 작업하는 방법

  15. 15

    핵심 데이터 : 개체 삭제 / 추가 오류

  16. 16

    일대 다 관계 핵심 데이터는 마지막 개체 만 저장합니다. 기타 누락

  17. 17

    속성 값이 정의 된 핵심 데이터 개체 수

  18. 18

    하나의 관리 개체로 핵심 데이터 미리 채우기

  19. 19

    이진 데이터 개체를 핵심 데이터 엔터티로 마이그레이션

  20. 20

    다른 tableView 섹션의 핵심 데이터 개체

  21. 21

    핵심 데이터 개체의 관계에 할당하면 개체가 손상된 것 같습니다.

  22. 22

    SQL 쿼리를 핵심 데이터 가져 오기 요청으로 교체

  23. 23

    핵심 데이터에서 이미지를로드하면 NavigationView 전환이 불안정 해집니다.

  24. 24

    많은 값을 포함하는 핵심 데이터 개체 업데이트

  25. 25

    핵심 데이터 개체 변경에 대한 SwiftUI 업데이트보기

  26. 26

    핵심 데이터에서 기존 개체와의 관계를 만드는 방법

  27. 27

    핵심 데이터는 목록 항목에 포함 된 개체를 찾습니다.

  28. 28

    핵심 데이터를 객체로 읽기

  29. 29

    핵심 데이터는 관리되는 개체를 저장하지만 데이터는 앱 실행 사이에 유지되지 않습니다.

뜨겁다태그

보관