Synchronizing issues of MBO in SUP 2.1.3 - iphone

I am trying to run an iOS application which is migrated from SUP2.1.2 to SUP2.1.3. An application is working fine with device registration and connection, but the problem arises when i try to synchronize 3 MBO synchronization group. The synchronization is working fine for the first time, but when i click over different item to synchronize its detail i am getting following error:
*** -[CFString retain]: message sent to deallocated instance 0x6465650
I think problem is coming under the following MBO method
+ (ITEMSSynchronizationParameters*)getSynchronizationParameters
{
return (ITEMSSynchronizationParameters*)[(SUPSyncParamEntityDelegate*)([[ITEMDATABASE delegate] getDelegate:#"ITEMSSynchronizationParameters"]) getSynchronizationParameters];
}
and i am calling this method while synchronizing app details as follows
ITEMSynchronizationParameters *syncParam = [ITEMSynchronizationParameters getSynchronizationParameters];
[syncParam setSYNC_NO:#"101"];
[syncParam save];
While It also not allowing me to delete sync parameter so that on each items click i should get different information details as [syncParam delete] is causing the same * -[CFString retain]: message sent to deallocated instance 0x6465650 error. I have used patch 01 and 02 but the problem is still present. Any help would be appreciated.

we had the same Problem.
In my case the answer for this problem was to create a locale property for the SynchronizationParameters and work with the Property. I don't know why but now the delicate error is gone.
#property (nonatomic, retain) ITEMSynchronizationParameters *item_sp;
item_sp = [Item getSynchronizationParameters];
item_sp.syncparam = #"XXXXX";
[item_sp save];

Related

Passing UISearchBar.text to another function

It's my first time working with a UISearchBar and so far it went fine, but now after clicking "search" I'm trying to pass the text to another function that handles the search.
[_searchModel searchIssueForTerm:searchBar.text inIssue:_dataModel.currentIssue];
This just throws me an error, saying:
-[CFString copyWithZone:]: message sent to deallocated instance 0x7dee900
But when I use this, it just works
[_searchModel searchIssueForTerm:#"test" inIssue:_dataModel.currentIssue];
Why is this hapenning? In my - (void)searchIssueForTerm:(NSString *)searchTerm inIssue:(Issue *)issue I store the NSString in another variable, why would it get deallocated then?
After searching for a while I managed to fix it by just saving the variable somewhere else, seems it was getting lost along the way.
_currentSearchTerm = [[NSString alloc] initWithString:searchTerm];

Why am I getting an "unrecognised selector sent to instance" error when I have defined the method?

I'm building an iOS (5.1) app on Xcode (4.4.1), and I'm almost done with the first phase of development, but I'm stuck on the final line of code. I've been using Kumulos as a backend & API solution, and at the moment all the API is working fine except for this bit:
Kumulos* k = [[Kumulos alloc]init];
[k setDelegate:self];
[k createNewTimePointWithJourneyIDFK:[journeyID integerValue]
andTime:currentDate andLat:[lat floatValue] andLon:[lon floatValue]];
When it hits the createNewTimePointWithJourneyIDFK: method, it terminates. In the log it mentions this method and says an unrecognised selector was sent to an instance.
Now I realise this question has been asked a million times on SO, but I've 1) checked that the method has been defined, and 2) that it has been called correctly (or at least to the best of my knowledge). The way I've done the above is the way I've done the rest of the API calls, and they work well, so I can't see what the problem is. Very frustrating, I've spent hours on this last line! So please don't think I've come hear after a few minutes of not knowing what to do.
The error message
2012-08-11 22:36:58.769 busApp4Kumulos[5485:707] -[Kumulos
createNewTimePointWithJourneyIDFK:andTime:andLat:andLon:]:
unrecognizedselector sent to instance 0x3d1b70 2012-08-11 22:36:58.778
busApp4Kumulos[5485:707]
*** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[Kumulos
createNewTimePointWithJourneyIDFK:andTime:andLat:andLon:]:
unrecognized selector sent to instance 0x3d1b70'
*** First throw call stack:
(0x35add88f 0x37e84259 0x35ae0a9b 0x35adf915 0x35a3a650 0x3ef5
0x37f86de3 0x37f86785 0x37f80e3f 0x35ab1b01 0x35ab112f 0x35ab0351
0x35a334a5 0x35a3336d 0x376cf439 0x3353fcd5 0x2dd9 0x2d74)
terminate called throwing an exception(lldb)
The Method
This is located in the Kumulos.m file.
-(KSAPIOperation*) createNewTimePointWithJourneyIDFK:(NSInteger)journeyIDFK
andTime:(NSDate*)time andLat:(float)lat andLon:(float)lon{
NSMutableDictionary* theParams = [[NSMutableDictionary alloc]init];
[theParams setValue:[NSNumber numberWithInt:journeyIDFK] forKey:#"journeyIDFK"];
[theParams setValue:time forKey:#"time"];
[theParams setValue:[NSNumber numberWithFloat:lat] forKey:#"lat"];
[theParams setValue:[NSNumber numberWithFloat:lon] forKey:#"lon"];
KSAPIOperation* newOp = [[KSAPIOperation alloc]initWithAPIKey:theAPIKey
andSecretKey:theSecretKey andMethodName:#"createNewTimePoint"
andParams:theParams];
[newOp setDelegate:self];
[newOp setUseSSL:useSSL];
//we pass the method signature for the kumulosProxy callback on this thread
[newOp setCallbackSelector:#selector( kumulosAPI: apiOperation: createNewTimePointDidCompleteWithResult:)];
[newOp setSuccessCallbackMethodSignature:[self methodSignatureForSelector:#selector(apiOperation: didCompleteWithResult:)]];
[newOp setErrorCallbackMethodSignature:[self methodSignatureForSelector:#selector(apiOperation: didFailWithError:)]];
[opQueue addOperation:newOp];
return newOp;
}
The only thing I can think of is that something got stale in your project. Have you tried cleaning (via Product → Clean) and rebuilding?

NSObjectInaccessibleException CoreData could not fulfill a fault - still confused

I see this issue has been asked a bit but all the answers seem to point to the cause being trying to update an object when the context has been deleted. I don't think I'm doing that but I'm getting the error so I'm confused (admittedly, I'm shaky on managing retention and references to begin with).
I have an Entity that holds user preferences as essentially key-value records. One of them is an email address.
UserPreference *prefEmailAddress;
#property (nonatomic, retain) UserPreference *prefEmailAddress;
In my class, in my ViewWillAppear method, I build a fetch request and get a reference to the email address value and set a UI text box to the value. This works fine.
NSArray *prefs = [context executeFetchRequest:request error: &error];
if ([prefs count] > 0) {
prefEmailAddress = [prefs objectAtIndex:0];
[prefEmailAddress setValue:emailAddress.text forKey:#"prefValue"];
}
However, in another method when I try to save the potentially modified text box text back to the object, I get the above crash.
I'm just doing this;
NSLog(#"Addr: %#",emailAddress.text);
// [prefEmailAddress setValue:emailAddress.text forKey:#"prefValue"];
The last line causes the exception. Seems like the prefEmailAddress object should still exist but it apparently doesn't.
Thanks for any hints on this.
I solved mine by removing
[fetchRequest setFetchBatchSize:<INT_VALUE>];
if this is in your code when fetching request.

Problem with NSManagedObjectContext crashing app

I have a navigation based app that uses Core Data for storage. The schema for this particular section is as follows:
Scene hasMany Tasks hasMany DeviceCommands
Tasks also have many other objects besides DeviceCommands (like DelayCommands etc), but this is beyond the scope of the problem (I think).
DeviceCommands also link to a parent object as follows:
Device hasMany DeviceCommands
Now, the user can create a new Task, which pops up a modal view to select the Device. When you select a device, a tableview is pushed with the DeviceCommands that belong to the Device. When you select a DeviceCommand, it assigns it to the Task with task.deviceCommand = device.deviceCommand. For some reason, and this only happens in this section of the app, the app crashes with the following output in the console:
2010-10-26 15:37:33.337 livOS4[47226:207] Serious application error. Exception was caught during Core Data change processing. This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification. * -[NSMutableArray objectAtIndex:]: index 35 beyond bounds [0 .. 0] with userInfo (null)
Index 35 refers to the index of the DeviceCommand in the UITableView and NSFetchedResultsController. Through a process of trial and error I've discovered that the NSMutableArray is the array with the Devices. If I add a new Device to the app, the array bounds are [0 .. 1].
I added an observer for NSManagedObjectContextObjectsDidChangeNotifications but it crashes before the observer receives anything.
Can anyone help or offer any advice for fixing this?
I have the same problems with NSFetchedResultsController.
Problem disappear then I add this to my viewController
- (void)dealloc
{
self.fetchedResultsController.delegate = nil;
self.fetchedResultsController = nil;
}
Fixed it this morning. Turned out to be a problem with how I was assigning the NSFetchedResultsController delegate.

Changing Core Data Items crashes App

I am running into another problem with my Iphone App which I just can't solve myself.
I implemented a kind of organizer functionality in my latest app.
There one can create appointments which are displayed in a tableview and persisted in a CoreDataStore. I use 4 classes:
an overview where appointments are displayed
a view with textfields to put in Values for place and name of appointment (create/edit view)
a view with DatePicker to define start- and enddate
a controller which handles creation and deletion of items using this methods:
The code:
-(void)createAppointmentObjectWithDate:(NSDate *)
appointmentDate name:(NSString *)appointmentName
description:(NSString *)appointmentDescription
eDate:(NSDate *)appointmentEndDate
{
NSManagedObjectContext *managedObjectContext = [[CoreDataManager sharedManager] managedObjectContext];
AppointmentObject *newAppointmentObject = [NSEntityDescription insertNewObjectForEntityForName:AppointmentObjectEntityName
inManagedObjectContext:managedObjectContext];
newAppointmentObject.appointmentName = appointmentName;
newAppointmentObject.appointmentDescription = appointmentDescription;
newAppointmentObject.appointmentDate = [appointmentDate earlierDate:appointmentEndDate];
newAppointmentObject.appointmentEndDate = [appointmentEndDate laterDate:appointmentDate];
}
-(void)deleteAppointmentObject:(AppointmentObject *)appointmentObject triggeredByUser:(BOOL)byUser{
NSManagedObjectContext *managedObjectContext = [[CoreDataManager sharedManager] managedObjectContext];
[managedObjectContext deleteObject:appointmentObject];
}
But all kind of crazy stuff is happening which makes my app crash with "SICBART" message:
2010-10-13 17:35:04.630 didacta[109:307] Serious application error. Exception was caught during Core Data change processing.
This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification.
-[CALayer controllerWillChangeContent:]: unrecognized selector sent to instance 0x19f150 with userInfo (null)
2010-10-13 17:35:05.118 didacta[109:307] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CALayer controllerWillChangeContent:]: unrecognized selector sent to instance 0x19f150'
errors appear while doing this:
creating new Appointment and pressing "Done" (should trigger creation and pop overview)
changing appointments and pressing "Done" (should send changes and pop overview)
tapping on an appointment in overview ( should pop create/edit view and hand over values)
deleting an item
sometimes I can even delete an appointment but then the order of the items in the tableview is somehow gotten twisted so the index of the tableview isn't pointing to the index of the appointment anymore.
Right.
-[CALayer controllerWillChangeContent:]: unrecognized selector sent to instance 0x19f150 with userInfo (null)
That's your error. You have an NSFetchedResultsController whose delegate is a CALayer. This sounds like the original delegate was deallocated and a CALayer was allocated using the same region of memory. The fix is to find the offending -dealloc and add something like self.myFetchedResultsController.delegate = nil; self.myFetchedResultsController = nil; assuming you're using properties.
You can sometimes help debugging things like this by enabling zombies (go to Project → Edit Current Executable or so, select Environment, add the NSZombieEnabled environment variable, and set its value to "YES" or so; uncheck the checkbox when you've finished debugging). Zombies cause an exception when a message is sent to a deallocated object. (Zombies are not deallocated by default, so your application will effectively leak; remember to uncheck the checkbox!).
"unrecognized selector" makes it sound like maybe your data model doesn't contain some of the Entity attributes that you're trying to use. For example, maybe you're trying to set an attribute of the object that doesn't exist.
Try creating a breakpoint at newAppointmentObject.appointmentName = appointmentName; and step through it to see at what point the error occurs.