Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

[NSManagedObjectContext delete:]: unrecognized selector sent to instance

Tags:

ios

core-data

core data getting on my nerves. i' m deleting old data and want to insert new data received from server.

now the deleting part gives a "sigabort":

-[NSManagedObjectContext delete:]: unrecognized selector sent to instance 0x522f550 2013-09-27 14:05:56.592 * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSManagedObjectContext delete:]: unrecognized selector sent to instance 0x522f550' * First throw call stack: (0x320f82a3 0x39d4797f 0x320fbe07 0x320fa531 0x32051f68 0x1b6c53 0x1868e5 0x3a15f11f 0x3a16d259 0x3a16d3b9 0x3a193a11 0x3a1938a4) libc++abi.dylib: terminate called throwing an exception

deleting happens in background and nsmanagedobjectcontext is a privet concurrency type i printed the pointer for context and object context

po context NSManagedObjectContext: 0x522f550

and

po tmpCon.managedObjectContext NSManagedObjectContext: 0x522f550>

and the code for deleting is:

     NSError *errorAllCons = nil;
    NSFetchRequest *allevents = [[NSFetchRequest alloc] init];
    [allevents setEntity:[NSEntityDescription entityForName:@"TEventContact" inManagedObjectContext:context]];
    NSArray *allCons = [context executeFetchRequest:allevents error:&errorAllCons];
    for (TEventContact *tmpCon in allCons)
    {
        [context delete:tmpCon];
    }

and it crashes on [context delete:tmpCon]; can someone let me know what am i doing wrong?

like image 710
Hashmat Khalil Avatar asked Nov 28 '22 21:11

Hashmat Khalil


1 Answers

Use

 [context deleteObject:tmpCon];

It will solve the problem

like image 88
Ratikanta Patra Avatar answered Dec 22 '22 07:12

Ratikanta Patra