Fixed build and runtime errors.

This commit is contained in:
Pietro Gagliardi 2015-08-02 23:05:16 -04:00
parent 2eb48aa129
commit 17a17b0d27
2 changed files with 17 additions and 16 deletions

View File

@ -59,8 +59,8 @@
- (void)tFillAutoLayout:(tAutoLayoutParams *)p - (void)tFillAutoLayout:(tAutoLayoutParams *)p
{ {
NSMutableDictionary *views; NSMutableDictionary *views;
__block uintmax_t n; __block uintmax_t i, n;
tAutoLayoutParams pp; __block tAutoLayoutParams pp;
__block BOOL anyStretchy; __block BOOL anyStretchy;
NSMutableString *constraint; NSMutableString *constraint;
@ -78,7 +78,7 @@
if ([isStretchy boolValue]) if ([isStretchy boolValue])
anyStretchy = YES; anyStretchy = YES;
[c tFillAutoLayout:&pp]; [c tFillAutoLayout:&pp];
[views setObjject:pp.view forKey:tAutoLayoutKey(n)]; [views setObject:pp.view forKey:tAutoLayoutKey(n)];
n++; n++;
}]; }];
@ -89,23 +89,23 @@
constraint = [NSMutableString stringWithString:@"H:|"]; constraint = [NSMutableString stringWithString:@"H:|"];
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
[constraint appendString:@"["]; [constraint appendString:@"["];
[constraint appendString:tAutoLayoutKey(n)]; [constraint appendString:tAutoLayoutKey(i)];
[constraint appendString:@"]"]; [constraint appendString:@"]"];
} }
[constraint appendString:@"|"]; [constraint appendString:@"|"];
[self->v addConstraint:[NSLayoutConstraint constraintsWithVisualFormat:constraint options:0 metrics:nil views:views]]; [self->v addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:constraint options:0 metrics:nil views:views]];
[constraint release]; // TODO do not release constraint; it's autoreleased?
// next make the views span the full other dimension // next make the views span the full other dimension
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if (self->vertical) if (self->vertical)
constraint = [NSMutableString stringWithString:@"H:|"]; constraint = [NSMutableString stringWithString:@"H:|["];
else else
constraint = [NSMutableString stringWithString:@"V:|"]; constraint = [NSMutableString stringWithString:@"V:|["];
[constraint appendString:tAutoLayoutKey(n)]; [constraint appendString:tAutoLayoutKey(i)];
[constraint appendString:@"]|"]; [constraint appendString:@"]|"];
[self->v addConstraint:[NSLayoutConstraint constraintsWithVisualFormat:constraint options:0 metrics:nil views:views]]; [self->v addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:constraint options:0 metrics:nil views:views]];
[constraint release]; // TODO do not release constraint; it's autoreleased?
} }
[views release]; [views release];

View File

@ -74,9 +74,9 @@
[constraint appendString:margin]; [constraint appendString:margin];
[constraint appendString:@"|"]; [constraint appendString:@"|"];
} }
constraints = [NSLayoutConstraint constraintsWithVisualFormat:constraint options:0 metrics:nil views:p.views]; constraints = [NSLayoutConstraint constraintsWithVisualFormat:constraint options:0 metrics:nil views:views];
[contentView addConstraints:constraints]; [contentView addConstraints:constraints];
[constraint release]; // TODO do not release constraint; it's autoreleased?
constraint = [NSMutableString stringWithString:@"V:"]; constraint = [NSMutableString stringWithString:@"V:"];
if (p.attachTop) { if (p.attachTop) {
@ -88,11 +88,12 @@
[constraint appendString:margin]; [constraint appendString:margin];
[constraint appendString:@"|"]; [constraint appendString:@"|"];
} }
constraints = [NSLayoutConstraint constraintsWithVisualFormat:constraint options:0 metrics:nil views:p.views]; constraints = [NSLayoutConstraint constraintsWithVisualFormat:constraint options:0 metrics:nil views:views];
[contentView addConstraints:constraints]; [contentView addConstraints:constraints];
[constraint release]; // TODO do not release constraint; it's autoreleased?
[views release]; // TODO do not release views; it's autoreleased?
// (for all of these, look up whether the constructor autoreleases)
} }
@end @end