CoreData 저장에 문제가 있습니다. 주 3 일이 기억 : 나는 세포에서 그들을 보여 게으른 다운로드 이미지를 해요 CoreData NSManagedObject의 속성 값을 설정 한 후 저장하는 동안 CoreData가 충돌 함
- .
- 아이콘 다운로드가 끝나면 이미지 데이터를 base64 문자열로 변환하고 해당 문자열을 CoreData에 저장합니다.
아이콘을 수신 한 후 CoreData 변경 사항을 저장하려고하면 문제가 발생합니다. 충돌이 발생합니다. NSManagedObject에 대한 변경 작업을 담당하는 코드의 일부분에 대해서는 아무런 문제가 없었지만, 충돌없이 해당 객체를 어떻게 저장할 수 있는지 알고 싶습니다. 내가 아이콘을 다운로드 후 NSManagedObject를 업데이트 곳입니다
는:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
if (self.activeDownload && [self.activeDownload length]>0) {
NSString* base64 = [self.activeDownload base64Encoding]; // converting data to base64
NSError* error= nil;
Offer* offerDB2 = [self.offer offerObject]; // Offer is NSManagedObject subclass of my Entity
if (offerDB2) {
[offerDB2 setImageData:base64]; // Setting property value (if commented -> no crash)
[CoreDataHandler save]; // This is where App crashes
}
}
self.activeDownload = nil;
self.imageConnection = nil;
[IconDownloader doNext];
}
지금 클래스를 제공
CrashLog 그렇게 보이는#import <CoreData/CoreData.h>
@interface Offer : NSManagedObject
{
}
@property (nonatomic, retain) NSString * bigInfo;
@property (nonatomic, retain) NSNumber * categoryID;
@property (nonatomic, retain) NSNumber * databaseID;
@property (nonatomic, retain) NSNumber * deleted;
@property (nonatomic, retain) NSString * descriptionString;
@property (nonatomic, retain) NSNumber * endDate;
@property (nonatomic, retain) NSString * extendedInfo;
@property (nonatomic, retain) NSNumber * offerType;
@property (nonatomic, retain) NSString * photoLink;
@property (nonatomic, retain) NSString * physicalUnit;
@property (nonatomic, retain) NSString * shopName;
@property (nonatomic, retain) NSNumber * size;
@property (nonatomic, retain) NSString * sizeUnit;
@property (nonatomic, retain) NSString * smallInfo;
@property (nonatomic, retain) NSNumber * startDate;
@property (nonatomic, retain) NSNumber * unitPrice;
@property (nonatomic, retain) NSString * unitPriceName;
@property (nonatomic, retain) NSString * imageData;
@end
#import "Offer.h"
@implementation Offer
@dynamic bigInfo;
@dynamic categoryID;
@dynamic databaseID;
@dynamic deleted;
@dynamic descriptionString;
@dynamic endDate;
@dynamic extendedInfo;
@dynamic offerType;
@dynamic photoLink;
@dynamic physicalUnit;
@dynamic shopName;
@dynamic size;
@dynamic sizeUnit;
@dynamic smallInfo;
@dynamic startDate;
@dynamic unitPrice;
@dynamic unitPriceName, imageData;
-(NSNumber*)sectionNumber{
return self.offerType;
}
@end
:
*** -[NSCFType evaluateWithObject:]: unrecognized selector sent to instance 0x4354210
Program received signal: “EXC_BAD_ACCESS”.
#0 0x32668ec0 in objc_msgSend
#1 0x32de2b5e in __CFExceptionProem
#2 0x32de2bcc in -[NSObject doesNotRecognizeSelector:]
#3 0x32d67b18 in ___forwarding___
#4 0x32d5e840 in __forwarding_prep_0___
#5 0x30537cbe in -[NSFetchedResultsController(PrivateMethods) _objectInResults:]
#6 0x30538d16 in -[NSFetchedResultsController(PrivateMethods) _preprocessUpdatedObjects:insertsInfo:deletesInfo:updatesInfo:sectionsWithDeletes:newSectionNames:treatAsRefreshes:]
#7 0x3053aa2c in -[NSFetchedResultsController(PrivateMethods) _managedObjectContextDidChange:]
#8 0x33f765d8 in _nsnote_callback
#9 0x32d9e510 in _CFXNotificationPostNotification
#10 0x33f741b2 in -[NSNotificationCenter postNotificationName:object:userInfo:]
#11 0x304b4388 in -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:]
#12 0x3050768a in -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:withDeletions:withUpdates:withRefreshes:]
#13 0x3049c2b0 in -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:]
#14 0x304cb186 in -[NSManagedObjectContext save:]
가능한 문제 :
- CoreData를 저장하는 동안 많은 양의 데이터를 처리 할 수 있습니다. base64로 변환 된 이미지는 많은 문자를 포함 할 수 있습니다.
- 라인 # 5, # 6, # 7은 NSFetchResultsController에 대해 말합니다.
, everuthing는 추락했다. "NowOffer" inManagedObjectContext @ : Ithink
NowOffer objBean = (NowOffer *) [NSEntityDescription 아래 insertNewObjectForEntityForName을 감안할 때처럼 실수가 작성이되어 어떻게 당신이 당신의 빈 (NowOffer)의 개체를 만들 수 있나요
당신이 당신의 자신의 질문에 대답하는 대신 대답 원래 질문을 수정하는 것이 바람직하다. 그런 다음 대답을 수락 할 수 있습니다. – albertamg