RestKit: App crashes in RKObjectRequestOperation.m on line 131 (objectRequestOpertationDidStart:)

When a user logs into my app, it does several request operations, but seems to crash when the object in the notification is ‘nil’. This is happening everytime.

RKObjectRequestOperation *objectRequestOperation = [notification object]; objc_setAssociatedObject(objectRequestOperation, RKOperationStartDate, [NSDate date], OBJC_ASSOCIATION_RETAIN_NONATOMIC);

objectRequestOpertation is sometimes nil.

I’ve updated to the latest development branch that added the “RKManagedObjectStore_Private.h” file.

Update: The notification being sent is from initWithHTTPRequestOperation:responseDescriptors:. WeakSelf is declared and then once it gets into the executeBlock of the stateMachine, weakSelf is nil.

It appears it is when I set the completion block and then just do [operation start] and then leave the method it was called. Looks like my operation is being deallocated. This is happening with the 0.27.0 release as well.

This was working using 0.20.3.

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Reactions: 5
  • Comments: 20 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Hi guy. Any news about this?

I’ve the same problem: IOS: 9.3.4 XCode: 7.3.1 Restkit: 0.27

Note: if i enqueue the operation it runs well. “[[RKObjectManager sharedManager] enqueueObjectRequestOperation:postOperation];”

Replace[[NSNotificationCenter defaultCenter] postNotificationName:RKObjectRequestOperationDidStartNotification object:weakSelf]; To [[NSNotificationCenter defaultCenter] postNotificationName:RKObjectRequestOperationDidStartNotification object:self];

Worked for me

Same crash here. iOS 10 XCode 8 RestKit 0.27.0 Seems like the operation is not retained, so it dies right after [operation start]; If I add operation to NSOperationQueue, it works ok.

@lazar-sidor I followed @silvaigor answer and it solved it

Use [[RKObjectManager sharedManager] enqueueObjectRequestOperation:operation]; Insted of [operation start];