CoreData parameter binding gives error '- [WeatherObservation count]: unrecognized selector sent to instance

WeatherObservationis an entity in my data model, I am trying to establish its relation to another object (one to one) through which I passed through the navigation controller. He worked a few weeks ago. I changed some of the other objects in my model, restored the classes, and this relationship was set to NSManagedObject, and not to the class for another object. I tried re-creating this class several times, then just changing it to what it should have and adding the class to .h, #import in .m

I assume that the message [MANAGEDOBJECT count] is part of the main data magic, I do not call it anywhere in my code. I don’t know where to start, what to do, what can I post here to help get an answer? I tried:

weather.hiveObservation = hiveObs;

and

[weather setValue:hiveObs forKey:@"hiveObservation"]

both produce the same error if I comment on setting the relationship stored by the object in persistent storage. hiveObscreated in the old view, but not yet saved ... if that matters?

EDIT: After a thought and added information.
The ManagedObject I pass in was created, but was not saved before changing the views. It registers with zero values ​​in the new view, but could this be a problem?


HiveObservation.h Master Data Files

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

@class BoxObservation, HiveDetails, WeatherObservation;

@interface HiveObservation : NSManagedObject
... //other properties omitted
@property (nonatomic, retain) HiveDetails *hiveDetail;
@property (nonatomic, retain) WeatherObservation *weatherObservation;
@end

@interface HiveObservation (CoreDataGeneratedAccessors)

- (void)addBoxObservationsObject:(BoxObservation *)value;
- (void)removeBoxObservationsObject:(BoxObservation *)value;
- (void)addBoxObservations:(NSSet *)values;
- (void)removeBoxObservations:(NSSet *)values;

@end

WeatherObservation.h

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

@class HiveObservation;

@interface WeatherObservation : NSManagedObject
//... other properties omitted
@property (nonatomic, retain) NSNumber * windSpeed;
@property (nonatomic, retain) HiveObservation *hiveObservation;

@end

Console output:

2015-01-21 14:28:32.739 Hive Maps[5085:69277] -[WeatherObservation count]: unrecognized selector sent to instance 0x78ea3140
2015-01-21 14:28:32.743 Hive Maps[5085:69277] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[WeatherObservation count]: unrecognized selector sent to instance 0x78ea3140'
*** First throw call stack:
(
    0   CoreFoundation                      0x0157b946 __exceptionPreprocess + 182
    1   libobjc.A.dylib                     0x01204a97 objc_exception_throw + 44
    2   CoreFoundation                      0x015835c5 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277
    3   CoreFoundation                      0x014cc3e7 ___forwarding___ + 1047
    4   CoreFoundation                      0x014cbfae _CF_forwarding_prep_0 + 14
    5   CoreData                            0x00b2a8cc -[NSSQLCore _knownOrderKeyForObject:from:inverseToMany:] + 204
    6   CoreData                            0x00b2ae53 -[NSSQLCore _populateRow:fromObject:timestamp:inserted:] + 1043
    7   CoreData                            0x00a52e73 -[NSSQLCore prepareForSave:] + 1091
    8   CoreData                            0x00a52174 -[NSSQLCore saveChanges:] + 340
    9   CoreData                            0x00a1bfee -[NSSQLCore executeRequest:withContext:error:] + 638
    10  CoreData                            0x00b15af4 __65-[NSPersistentStoreCoordinator executeRequest:withContext:error:]_block_invoke + 5380
    11  CoreData                            0x00b1ee9c gutsOfBlockToNSPersistentStoreCoordinatorPerform + 188
    12  libdispatch.dylib                   0x02d00e2f _dispatch_client_callout + 14
    13  libdispatch.dylib                   0x02ce5505 _dispatch_barrier_sync_f_invoke + 144
    14  libdispatch.dylib                   0x02ce4c37 dispatch_barrier_sync_f + 105
    15  CoreData                            0x00b0f7e7 _perform + 183
    16  CoreData                            0x00a1bb1b -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 459
    17  CoreData                            0x00a4b1d9 -[NSManagedObjectContext save:] + 1529
    18  Hive Maps                           0x00018a6d -[GetWeatherTableViewController saveWeatherData:] + 3133
    19  libobjc.A.dylib                     0x0121a7cd -[NSObject performSelector:withObject:withObject:] + 84
    20  UIKit                               0x0193023d -[UIApplication sendAction:to:from:forEvent:] + 99
    21  UIKit                               0x01ca0840 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 139
    22  libobjc.A.dylib                     0x0121a7cd -[NSObject performSelector:withObject:withObject:] + 84
    23  UIKit                               0x0193023d -[UIApplication sendAction:to:from:forEvent:] + 99
    24  UIKit                               0x019301cf -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
    25  UIKit                               0x01a63e86 -[UIControl sendAction:to:forEvent:] + 69
    26  UIKit                               0x01a642a3 -[UIControl _sendActionsForEvents:withEvent:] + 598
    27  UIKit                               0x01a6350d -[UIControl touchesEnded:withEvent:] + 660
    28  UIKit                               0x0198060a -[UIWindow _sendTouchesForEvent:] + 874
    29  UIKit                               0x019810e5 -[UIWindow sendEvent:] + 791
    30  UIKit                               0x01946549 -[UIApplication sendEvent:] + 242
    31  UIKit                               0x0195637e _UIApplicationHandleEventFromQueueEvent + 20690
    32  UIKit                               0x0192ab19 _UIApplicationHandleEventQueue + 2206
    33  CoreFoundation                      0x0149f1df __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    34  CoreFoundation                      0x01494ced __CFRunLoopDoSources0 + 253
    35  CoreFoundation                      0x01494248 __CFRunLoopRun + 952
    36  CoreFoundation                      0x01493bcb CFRunLoopRunSpecific + 443
    37  CoreFoundation                      0x014939fb CFRunLoopRunInMode + 123
    38  GraphicsServices                    0x04d0124f GSEventRunModal + 192
    39  GraphicsServices                    0x04d0108c GSEventRun + 104
    40  UIKit                               0x0192e8b6 UIApplicationMain + 1526
    41  Hive Maps                           0x0001967d main + 141
    42  libdyld.dylib                       0x02d2cac9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException  

, , :

weather.hiveObservation = hiveObs;       
NSError *error = nil;
if (![_managedObjectContext save:&error]) {
     //Handle the error.
     NSLog(@"SAVE ERROR: %@",error);
}   

,

+4
1

. . , , .

: "hiveObservation" Entity ( ), .

+10

All Articles