NSError release: message sent to the freed instance

I get an error message in an iOS 7 application with the following error:

-[NSError release]: message sent to deallocated instance 0x3c443fe0

An error is triggered when a call is added to the following method:

-(void)loadMessages:(NSString*)customerUID {
  NSString *formatUID = [NSString stringWithFormat:@"%s%@%s", "'", customerUID, "'"];
  formatUID = [formatUID stringByReplacingOccurrencesOfString:@"'" withString:@"%27"];
  NSString *servicePath = [NSString stringWithFormat:@"/api/messagerecipient?messageid=null&customeruid=%@", formatUID];

  [[RKObjectManager sharedManager] getObjectsAtPath:servicePath parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *messagesResult)
  {
    NSArray *messageResults = messagesResult.array;

    if (messageResults != nil || [messageResults count] != 0)
    {
      //Add some code here
    }
  } failure:^(RKObjectRequestOperation *operation, NSError *error) {

    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"An Error Has Occurred" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alertView show];
  }];
}

I added several breakpoints to the code at different points and did not return any error details. In addition, nothing in the console protocol indicates what the problem is (I added the full RestKit log), just above NSErrorthe release message.

I also run a Zombie scan in Tools. He shows the following.

Tools

I am confused because it shows that a zombie is created by a challenge GSEventRunModal. When I go to the advanced part and select the call, it will display the following:

Extended Part

Any pointers would be greatly appreciated, thanks.

:

enter image description here

+4
5

, , , Core Data. MagicalRecord ( RestKit), , . . , MagicalRecord , Core Data .

, Apple , , . , , - , , . , .

+2

, AlertView ? ?

UIAlertView iOS?

0

:

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"An Error Has Occurred" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alertView show];

NSString * message = [error localizedDescription];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"An Error Has Occurred" message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alertView show];

, init .

0

, , .

, NSERROR.

please check the instance of the class that contains the method you are calling and make sure it is not freed.

or add the calling method to the question so we can test it.

0
source

In my case, it helped to link the database with a separate context. I used the following class constructor that received the message:

    -(id)init {
    self = [super init];
    if (self) {
        self.managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
        self.managedObjectContext.parentContext = [(AppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];
        self.managedObjectContext.retainsRegisteredObjects = YES;
    }

    return self;
}
0
source

Source: https://habr.com/ru/post/1532181/


All Articles