Corrected property works in iOS5 but not iOS6

I have a serious problem in my CoreData database. I created a One-to-Many relationship between two tables and added an added property to the table that contains all the unique values. All code works as expected in iOS 5, but in iOS 6 I get the following error message:

2013-02-08 15: 15: 49.382 ArdsBoroughCouncil [16152: c07] * The application terminated due to the uncaught exception "NSUnknownKeyException", reason: '[<_NSObjectID_48_0 0xb25c3b0> valueForUndefinedKey:]: this class is not a key value compatible with the encoding for the tour_id key. '* The first call stack cast: (0x31c7012 0x24a3e7e 0x324ffb1 0x1c445ed 0x1bb08db 0x1bb088d 0x1bceb17 0x1bfe746 0x21b74bb 0x21b7176 0x21b6e44 0x21b66f4 0x21b2d63 0x21b2a82 0x21b2850 0x21b2625 0x21b1e07 0x21b18f4 0x21b0a6d 0x21ae9c9 0x2201276 0x227b155 0x2201071 0x2880014 0x286fd5f 0x286faa3 0x220103b 0x2200e9e 0x21ae9c9 0x2209dfa 0x22375cf 0x2237a03 0x59de1 0x11c2753 0x11c2a7b 0x11d0590 0x11d85bd 0x11d8eab 0x11d94a3 0x11d9098 0x1534da3 0x1526ad9 0x1526b54 0x24b7705 0x10e2920 0x10e28b8 0x11a3671 0x11a3bcf 0x11a2d38 0x111233f 0x1112552 0x10f03aa 0x10e1cf8 0x34b3df9 0x34b3ad0 0x313cbf5 0x313c962 0x316db266 0x341bf26f4f 0x161bf26f4f0bfcfc

The predicate defined for the selected property:

($ FETCH_SOURCE.tour_id == tour_id) AND ($ FETCH_SOURCE! = SELF)

Tour.

- Fetched Properties wihtin iOS 6? , iOS 5, iOS6.

, :

, :

- (void)loadRecordsFromCoreData {
    [self.managedObjectContext performBlockAndWait:^{
        [self.managedObjectContext reset];
        NSError *error = nil;
        NSFetchRequest *request = [[NSFetchRequest alloc] init];
        NSEntityDescription *entityDescription = [NSEntityDescription entityForName:NSStringFromClass([Tour class]) inManagedObjectContext:self.managedObjectContext];
        [request setEntity:entityDescription];
        [request setResultType:NSManagedObjectResultType];
        [request setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"tour_id" ascending:YES]]];
        self.tours = [self.managedObjectContext executeFetchRequest:request error:&error];
    }];

NSManagedObjects, :

- Tour

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>

@class TourDetail;

@interface Tour : NSManagedObject

@property (nonatomic, retain) NSNumber * tour_id;
@property (nonatomic, retain) NSString * background_url;
@property (nonatomic, retain) NSString * summary;
@property (nonatomic, retain) NSString * title;
@property (nonatomic, retain) NSSet *tourdetails_tour;

@property (nonatomic, retain) NSArray *tourDetails;
@end

@interface Tour (CoreDataGeneratedAccessors)

- (void)addTourdetails_tourObject:(TourDetail *)value;
- (void)removeTourdetails_tourObject:(TourDetail *)value;
- (void)addTourdetails_tour:(NSSet *)values;
- (void)removeTourdetails_tour:(NSSet *)values;

@end
}
#import "Tour.h"
#import "TourDetail.h"


@implementation Tour

@dynamic tour_id;
@dynamic background_url;
@dynamic summary;
@dynamic title;
@dynamic tourdetails_tour;
@dynamic tourDetails;

@end

-

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>

@class Tour;

@interface TourDetail : NSManagedObject

@property (nonatomic, retain) NSNumber * id;
@property (nonatomic, retain) NSNumber * tour_id;
@property (nonatomic, retain) NSNumber * lattitude;
@property (nonatomic, retain) NSNumber * longitude;
@property (nonatomic, retain) NSString * audiofile;
@property (nonatomic, retain) NSString * detail;
@property (nonatomic, retain) NSString * title;
@property (nonatomic, retain) Tour *tour_tourdetails;

@end

#import "TourDetail.h"
#import "Tour.h"


@implementation TourDetail

@dynamic id;
@dynamic tour_id;
@dynamic lattitude;
@dynamic longitude;
@dynamic audiofile;
@dynamic detail;
@dynamic title;
@dynamic tour_tourdetails;

@end

, , :) , , ?

,

+5
1

, , .

- (void)loadRecordsFromCoreData {
    [self.managedObjectContext performBlockAndWait:^{
        [self.managedObjectContext reset];
        NSError *error = nil;
        NSFetchRequest *request = [[NSFetchRequest alloc] init];
        NSEntityDescription *entityDescription = [NSEntityDescription entityForName:NSStringFromClass([Tour class]) inManagedObjectContext:self.managedObjectContext];
        [request setEntity:entityDescription];
        [request setResultType:NSManagedObjectResultType];
        [request setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"tour_id" ascending:YES]]];
        self.tours = [self.managedObjectContext executeFetchRequest:request error:&error];
    }];

.

, , , , self.tours . . , ?

.

+(void)loadRecordsWithCompletion:(void(^)(NSArray *records, NSError *error))completion {
    NSManagedObjectContext *context; //Your context
    NSError *error;
    NSSortDescriptor *sortDesc = [NSSortDescriptor sortDescriptorWithKey:@"attribute" ascending:YES];
    NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"EntityName"];
    [request setSortDescriptors:@[sortDesc]];
    NSArray *records = [context executeFetchRequest:request
                                              error:&error];
    completion(records, error);
}
0

All Articles