1

I have a crash in Fabric that points to the first line in Objective-C:

somePromise.then(^ {
  // some more code
});

The app is using PromiseKit. Why is this crashing?

Johannes Fahrenkrug
  • 42,912
  • 19
  • 126
  • 165

1 Answers1

1

The answer is: In some cases somePromise might be nil. Calling a method on nil (or "sending a message to nil") in Objective-C should be perfectly fine, though, right?

Well, in this case the code isn't actually trying to send an Objective-C message to nil. Instead, it is trying to execute a block that is nil. It's like doing this:

void (^block)() = nil;
block();  // CRASH!

So: make sure the promise is not nil before calling then on it.

Thanks to @mxcl for giving me the solution here: https://github.com/mxcl/PromiseKit/issues/344#issuecomment-167020593

Johannes Fahrenkrug
  • 42,912
  • 19
  • 126
  • 165