ONLY_ACTIVE_ARCH

debug YES becoz u only want to build in your testing device (or compile too long time and waste the other arch build)

release NO u should make sure all ios devices can run

set segue.destinationViewController property

method 1. typecast

APPDetailViewController myController = (APPDetailViewController)segue.destinationViewController;
myController.myString = string;

method 2. selector

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.destinationViewController respondsToSelector:@selector(setMyData:)]) {
         [segue.destinationViewController performSelector:@selector(setMyData:) 
                                               withObject:myData];
    } 
}

in destination View Controller

@property (nonatomic, strong) MyData *myData;

Assertion failure in -[XXXView layoutSublayersOfLayer:]

2014-08-06 12:17:02.511 Jtab[6255:60b] *** Assertion failure in -[JTChordCollectionView layoutSublayersOfLayer:], /SourceCache/UIKit/UIKit-2935.138/UIView.m:8794 2014-08-06 12:17:02.512 Jtab[6255:60b] *** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘Auto Layout still required after executing -layoutSubviews. JTChordCollectionView’s implementation of -layoutSubviews needs to call super.’

    [super layoutSubviews];

    [chordLabelView makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(labelPlaceHolder.centerX);
        make.centerY.equalTo(labelPlaceHolder.centerY);
    }];

solve by add [super layoutSubviews]; before add constraints ….

fitFontSize

-(void)fitFontSize:(UILabel*)label {
CGFloat actualFontSize;
[label.text sizeWithFont:label.font
minFontSize:label.minimumFontSize
actualFontSize:&actualFontSize
forWidth:label.bounds.size.width
lineBreakMode:label.lineBreakMode];
label.font = [label.font fontWithSize:actualFontSize];
label.adjustsFontSizeToFitWidth = NO;
}

usage: self.keyLabel = [self makeLabel:[UIFont fontWithName:@”AkzidenzGroteskBE-BoldCn” size:45.0f]];

    self.keyLabel.frame = CGRectMake(0, 0, self.cellWidth / 4.0, self.cellHeight);
    self.keyLabel.text = @"C";

    [self fitFontSize:self.keyLabel];
    [self.keyLabel sizeToFit];
    [self.keyLabel makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.centerX);
        make.centerY.equalTo(self.centerY);
    }];

Masonry in ios

constraints is funny

if u use Masonry or updateConstraints to a UIView, may no reaction till u drag one constraints to it…

Becoz

  1. storyboard default has constraints already (if u dun drag any) it just the current frame be the constraints (if u tick autolayout which is usually ticked)
  2. when u drag the constraints, it override
  3. when u code using Masonry or constrains programming, it override

But sometimes it will say broken, becoz the constraints jammed… so… one solution: http://img.thissoso.com/img/2/cee33f4f55e0.png

it will ignore all the storyboard constraints, so u can use the coding one now.