constraintsWithVisualFormat crashing the app for no apparent reason

Originator:denis.poifol
Number:rdar://28771762 Date Originated:14/10/2016
Status:Open Resolved:
Product:iOS Product Version:9 and above
Classification: Reproducible:
 
Summary:
My application crashes randomly due to :
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse constraint format: 
Unable to interpret '|' character, because the related view doesn't have a superview 
H:|[container]|
The incriminated line is the following :
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:[NSString stringWithFormat:@"%@:|[container]|", vertically ? @"H" : @"V"]

consider that the relative variable is not null and is set as a subview two line before the constraint is added to its superView

Steps to Reproduce:
Unknown

Expected Results:
Application shouldn't crash

Actual Results:
Application Crashes

Version:
ios 9 and higher

Notes:


Configuration:
iPad (all kinds) mostly but also iPod touch, iPhone 4s, iPhone 5, iPhone 5s, iPhone5c

Attachments:
'crashing function' was successfully uploaded.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!