In an edit window, choosing "Tap here to see the final preview" causes the SE iOS app to close. Sometimes, but not always, there's a very brief white screen with the word Preview on top. It doesn't last long enough to take a screenshot.

The issue is frequent but random, occurring either a number of times in a row, or not until after a very few successful edits. I've encountered it:

  • on five different sites, including here on meta.
  • on both questions and answers, regardless of their length or presence of pictures or formatting.
  • during edits of any number of characters.
  • with or without changing any text on the site where I have full edit privileges.

It occurs whether or not I have other apps open. Re-booting doesn't help.

Because it's intermittent, I don't know if it's version specific, but for me it began immediately after installation of version I have not changed anything on my device, which is iPad 2 running iOS 9.1.

1 Answer 1


This is fixed in

The issue comes from some weird code and a bad assumption on my part. When we show a normal question and answer page, we use a SEQuestionAndAnswerViewController with its data backed by a SEQuestionStore. For simplicity's sake, full question and answer previews use much of the same code as SEQuestionAndAnswerViewController (via a shared superclass SEPostViewController), including the SEQuestionStore.

This last part is important, because SEQuestionStore only deals in term of questions while previews can be in terms of answers, suggested edits, or just the extremely light-weight question responses from /questions/render. As such, basic shell models are often created to shoehorn these models into questions and this leads to a question or answer sometimes missing an owner field.

So, why is this suddenly crashing?

We have a not-yet-formally-announced-but-I'm-really-excited-about-it feature going into the iOS app which is very interested in the user IDs that will be displayed on a post. As such, when we load a question in SEQuestionStore, it collects the user IDs with the following line:

NSSet<NSNumber *> *userIds = [[[BITE(@[question]) and:question.answers] mapWithKeyPath:@"owner.userId"] set];

This code uses my bite-objc functional enumerator library to create an enumerator of the question and answers (posts), map it to the owner user id and convert it to a set. Bite heavily leverages the NSFastEnumeration protocol which unlike Foundation collections has no issue with nil entities, meaning that if we make a fake question to wrap a newly returned answer and question.owner == nil, we end up with an enumerator of (nil, 272239). When we build the set and add nil to it, the app crashes.

The solution is to filter nil out of the enumerator before converting to the set:

NSSet<NSNumber *> *userIds = [[[[BITE(@[question]) and:question.answers] mapWithKeyPath:@"owner.userId"] filterWithFormat:@"self != nil"] set];

The funny thing is, I wrote most of this new feature in Swift because I absolutely didn't want it to break on runtime stuff like this. I guess I should have written this method in Swift with a signature like preloadWithQuestion(_:SEAPIQuestion, site:SEAPISite)

  • 1
    No doubt a candidate for the most detailed fix report ever. ;) Nov 30, 2015 at 20:09
  • I have to agree. This is like going to a programming class for free! I've spent the last hour trying very hard to re-create the problem, and I can't, so thanks for the education and the fix! Dec 1, 2015 at 22:05
  • Way off topic but while I have you... Would you kindly tell me how to discard my edits in progress, of which there are now many! I'm sure it's something simple that I just can't find. Thanks! Dec 1, 2015 at 22:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .