- (voID)tableVIEw:(UItableVIEw *)tableVIEw commitEditingStyle:forRowAtIndexPath:
当我滑动删除时调用此方法,当我点击删除按钮时出现以下错误:
-[Vehicle removeObjectFromGasUpsAtIndex:]: unrecognized selector sent to instance 0x8172c60
我的NSManagedobject类Vehicle有一个名为gasUps的NSOrderedSet变量,当我要删除它时,它应响应此消息.或者我想.
这是崩溃的整个方法:
- (voID)tableVIEw:(UItableVIEw *)tableVIEw commitEditingStyle:(UItableVIEwCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{ if (editingStyle == UItableVIEwCellEditingStyleDelete) { // need to delete gas up and not vehicle int row = [indexPath row]; //[self.selectedVehicle removeObjectFromGasUpsAtIndex:row]; [self.selectedVehicle removeObjectFromGasUpsAtIndex:row]; NSError *error = nil; if (![self.managedobjectContext save:&error]) { // Replace this implementation with code to handle the error appropriately. // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipPing application,although it may be useful during development. NSLog(@"Unresolved error %@,%@",error,[error userInfo]); abort(); } } }
为什么这个选择器无法识别?
编辑:这是为了Jody.
#import <Foundation/Foundation.h>#import <CoreData/CoreData.h>typedef enum { FullExtract,nameExtract} kTitleExtract;@interface Vehicle : NSManagedobject@property (nonatomic,retain) Nsstring * name;@property (nonatomic,retain) NSNumber * year;@property (nonatomic,retain) Nsstring * make;@property (nonatomic,retain) NSNumber * mileage;@property (nonatomic,retain) Nsstring * model;@property (nonatomic,retain) NSOrderedSet *gasUps;// added methods- (Nsstring *)getTitleExtract:(kTitleExtract)TitleExtract;@end@interface Vehicle (CoreDataGeneratedAccessors)- (voID)insertObject:(NSManagedobject *)value inGasUpsAtIndex:(NSUInteger)IDx;- (voID)removeObjectFromGasUpsAtIndex:(NSUInteger)IDx;- (voID)insertGasUps:(NSArray *)value atIndexes:(NSIndexSet *)indexes;- (voID)removeGasUpsAtIndexes:(NSIndexSet *)indexes;- (voID)replaceObjectInGasUpsAtIndex:(NSUInteger)IDx withObject:(NSManagedobject *)value;- (voID)replaceGasUpsAtIndexes:(NSIndexSet *)indexes withGasUps:(NSArray *)values;- (voID)addGasUpsObject:(NSManagedobject *)value;- (voID)removeGasUpsObject:(NSManagedobject *)value;- (voID)addGasUps:(NSOrderedSet *)values;- (voID)removeGasUps:(NSOrderedSet *)values;@end
以下是设置self.selectedVehicle的代码片段:
if (self.vehiclesArray != nil && [self.vehiclesArray count] != 0 && self.vehicleIndex != -1) { // enable add buttom [self.navigationItem.rightbarbuttonItem setEnabled:YES]; self.selectedVehicle = [self.vehiclesArray objectAtIndex:self.vehicleIndex]; NSLog(@"set selected vehicle");} else { // disable add button [self.navigationItem.rightbarbuttonItem setEnabled:NO]; // set vehicle defaults to -1 and make disable add buttom NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setInteger:-1 forKey:@"vehicleIndex"]; [defaults synchronize]; NSLog(@"set index to -1");}解决方法 这可能与有序一对多关系的Core Data自动生成的访问器中的已知错误有关.
rdar://10114310
在解决此问题之前,您需要为缺少的访问者提供自己的实现.
见@L_404_1@的答案
总结以上是内存溢出为你收集整理的ios – 核心数据崩溃 – 无法识别的选择器全部内容,希望文章能够帮你解决ios – 核心数据崩溃 – 无法识别的选择器所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)