I have 2 viewcontrollers. One contain button from which I am sending request to server and in another viewcontroller I am displaying data in tableview. Now my application crashed sometimes not everytime when it is executing tableview method. I got crashed at method CFRetain Here is my log.
Here is my code of tableview:
#import "SearchResultViewController.h"
#import "UIImageView+AFNetworking.h"
#import "SearchResultCell.h"
#interface SearchResultViewController ()
#end
#implementation SearchResultViewController
- (id)initWithStyle:(UITableViewStyle)style {
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
UIBarButtonItem *btnHelp = [[UIBarButtonItem alloc] initWithTitle:#"Help" style:UIBarButtonItemStylePlain target:self action:#selector(btnHelpAction:)];
self.navigationItem.rightBarButtonItem=btnHelp;
self.title = #"Search Result";
}
-(IBAction)btnHelpAction:(id)sender{
HelpViewController *HVC=[[HelpViewController alloc]init];
UINavigationController *helpNavController=[[UINavigationController alloc]initWithRootViewController:HVC];
[self presentViewController:helpNavController animated:YES completion:nil];}
- (void)setTitle:(NSString *)title {
// [super setTitle:title];
UILabel *titleView = (UILabel *)self.navigationItem.titleView;
if (!titleView) {
titleView = [[UILabel alloc] initWithFrame:CGRectZero];
titleView.backgroundColor = [UIColor clearColor];
titleView.font = [UIFont fontWithName:GZFont size:16.0];
titleView.textColor = [UIColor colorWithRed:241/255.0 green:90/255.0 blue:41/255.0 alpha:1.0];
self.navigationItem.titleView = titleView;
}
titleView.text = title;
[titleView sizeToFit];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [MyAppDelegate.searchResultArray count];
// return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1; //changes
}
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 100;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
SearchResultCell *cell = [tableView dequeueReusableCellWithIdentifier:#"SearchResultCell"];
NSArray *tempSearchArray=[MyAppDelegate.searchResultArray objectAtIndex:indexPath.section];
if (cell == nil) {
NSArray *topLevelObject;
topLevelObject = [[NSBundle mainBundle] loadNibNamed:#"SearchResultCell" owner:self options:nil];
cell = [topLevelObject objectAtIndex:0];
}
NSLog(#"%#",[tempSearchArray objectAtIndex:0]);
cell.lblUsername.text = [tempSearchArray objectAtIndex:0];
cell.lblNumber.text = [NSString stringWithFormat:#"%#",[tempSearchArray objectAtIndex:1]];
if([tempSearchArray objectAtIndex:2]==[NSNull null])
{
NSLog(#"nullll");
cell.lblFirst_name.text=#"";
}
else{
cell.lblFirst_name.text = [tempSearchArray objectAtIndex:2];
}
cell.lblLast_name.text = [tempSearchArray objectAtIndex:3];
cell.lblEstablishment.text = #"E1123522";
if ([[[NSUserDefaults standardUserDefaults] valueForKey:#"UserLogedInType"] intValue] == LoginTypeFacebook) {
if ([[NSUserDefaults standardUserDefaults] objectForKey:#"FBUserLogedInProfileData"] != [NSNull null]) {
NSMutableDictionary *FBUserProfileData = [[NSMutableDictionary alloc] initWithDictionary:[[NSUserDefaults standardUserDefaults] objectForKey:#"FBUserLogedInProfileData"]];
[cell.imgIcon setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:#"https://graph.facebook.com/%#/picture?width=100&height=100",[FBUserProfileData objectForKey:#"id"]]]
placeholderImage:[UIImage imageNamed:#"icon.png"]];
}
}
else {
if([[tempSearchArray objectAtIndex:6] boolValue]==1){
ASIFormDataRequest *_requestImage = [[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:URLGetImage]];
__unsafe_unretained ASIFormDataRequest *requestImage = _requestImage;
[requestImage setPostValue:[tempSearchArray objectAtIndex:4] forKey:#"user_id"];
[requestImage startAsynchronous];
[requestImage setCompletionBlock:^{
NSLog(#"proimage%#",[requestImage responseData]);
cell.imgIcon.image=[UIImage imageWithData:[requestImage responseData] scale:1.0f];
}];
}
else{
[cell.imgIcon setImage:[UIImage imageNamed:#"No_image.png"]];
}
}
cell.imgIcon.layer.cornerRadius = 3.0;
cell.imgIcon.layer.masksToBounds = YES;
DYRateView *rateView = [[DYRateView alloc] initWithFrame:CGRectMake(90, 75, 120, 20)
fullStar:[UIImage imageNamed:#"StarFullLarge.png"]
emptyStar:[UIImage imageNamed:#"StarEmptyLarge.png"]];
rateView.padding = 2;
rateView.rate =[[tempSearchArray objectAtIndex:5] floatValue];
//NSLog(#"rating value%f",[[tempSearchArray objectAtIndex:4] floatValue]);
rateView.alignment = RateViewAlignmentCenter;
rateView.editable = YES;
rateView.delegate = self;
rateView.editable = NO;
[cell addSubview:rateView];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
SearchedProfileViewController *profileVC=[[SearchedProfileViewController alloc]init];
profileVC.cellId=indexPath.section;
NSLog(#"%d",profileVC.cellId);
[self.navigationController pushViewController:profileVC animated:YES];
//[self presentViewController:profileVC animated:YES completion:nil];
}
- (void)rateView:(DYRateView *)rateView changedToNewRate:(NSNumber *)rate {
// self.rateLabel.text = [NSString stringWithFormat:#"Rate: %d", rate.intValue];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
#end
updated crash log:
Objective: {objective 0xda869f0: <1:568> + <1:0.5>*0xd982420.marker{id: 726} + <1:-0.5>*_UIParallaxDimmingView:0x1186bb10.Height{id: 707}}
2013-12-05 14:41:01.318 GratZeez[1567:3503] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '<NSISEngine: 0xc67f090>{ Rows:
0xc67fa30.negError{id: 631} == 6 + -1*0xc67d5e0:IB auto generated at build time for view with fixed frame.marker{id: 495} + 1*0xc67fa30.posErrorMarker{id: 630}
0xc685ce0.posErrorMarker{id: 644} == 132 + 1*0xc68b900:IB auto generated at build time for view with fixed frame.marker{id: 509} + 1*0xc685ce0.negError{id: 645}
0xc6888b0.posErrorMarker{id: 658} == 106 + 1*0xc68b9c0:IB auto generated at build time for view with fixed frame.marker{id: 517} + 1*0xc6888b0.negError{id: 659}
0xc6888f0.posErrorMarker{id: 660} == 0 + 1*0xc67b5d0:IB auto generated at build time for view with fixed frame.marker{id: 519} + 1*0xc6888f0.negError{id: 661}
0xc69ffd0.posErrorMarker{id: 646} == 0 + 1*0xc68b930:IB auto generated at build time for view with fixed frame.marker{id: 511} + 1*0xc69ffd0.negError{id: 647}
0xc6b3200.posErrorMarker{id: 628} == 90 + 1*0xc67ace0:IB auto generated at build time for view with fixed frame.marker{id: 493} + 1*0xc6b3200.negError{id: 629}
0xc6b45d0.posErrorMarker{id: 636} == 114 + 1*0xc67d670:IB auto generated at build time for view with fixed frame.marker{id: 501} + 1*0xc6b45d0.negError{id: 637}
0xc6b4620.posErrorMarker{id: 638} == 0 + 1*0xc67d6a0:IB auto generated at build time for view with fixed frame.marker{id: 503} + 1*0xc6b4620.negError{id: 639}
0xc6b4dc0.posErrorMarker{id: 664} == 72 + 1*0xc67b660:IB auto generated at build time for view with fixed frame.marker{id: 525} + 1*0xc6b4dc0.negError{id: 665}
0xc6b4e00.posErrorMarker{id: 667} == 0 + 1*0xc67b690:IB auto generated at build time for view with fixed frame.marker{id: 527} + 1*0xc6b4e00.negError{id: 668}
0xd9707e0.posErrorMarker{id: 589} == 128 + 1*0xc6b34d0:IB auto generated at build time for view with fixed frame.marker{id: 553} + 1*0xd9707e0.negError{id: 590}
0xd970820.posErrorMarker{id: 591} == 0 + 1*0xc6b3500:IB auto generated at build time for view with fixed frame.marker{id: 555} + 1*0xd970820.negError{id: 592}
0xd974070.posErrorMarker{id: 585} == 104 + 1*0xc6b3410:IB auto generated at build time for view with fixed frame.marker{id: 545} + 1*0xd974070.negError{id: 586}
0xd977ca0.posErrorMarker{id: 632} == 90 + 1*0xc6b3650:IB auto generated at build time for view with fixed frame.marker{id: 569} + 1*0xd977ca0.negError{id: 633}
0xd977dd0.posErrorMarker{id: 634} == 0 + 1*0xc6b3680:IB auto generated at build time for view with fixed frame.marker{id: 571} + 1*0xd977dd0.negError{id: 635}
0xd97a6d0.negError{id: 588} == 6 + -1*0xc6b3440:IB auto generated at build time for view with fixed frame.marker{id: 547} + 1*0xd97a6d0.posErrorMarker{id: 587}
0xd97ac70.posErrorMarker{id: 640} == 72 + 1*0xc6b3710:IB auto generated at build time for view with fixed frame.marker{id: 577} + 1*0xd97ac70.negError{id: 641}
0xd97acd0.posErrorMarker{id: 642} == 0 + 1*0xc6b3740:IB auto generated at build time for view with fixed frame.marker{id: 579} + 1*0xd97acd0.negError{id: 643}
0xd97cfb0.posErrorMarker{id: 601} == 200 + 1*0xc6b3590:IB auto generated at build time for view with fixed frame.marker{id: 561} + 1*0xd97cfb0.negError{id: 602}
0xd97cff0.posErrorMarker{id: 603} == 42 + 1*0xc6b35c0:IB auto generated at build time for view with fixed frame.marker{id: 563} + 1*0xd97cff0.negError{id: 604}
SearchResultCell:0xc6ade20.Height{id: 652} == 200 + 1*0xd97b820.marker{id: 655}
SearchResultCell:0xc6ade20.Width{id: 650} == 640 + 2*0xd97b7c0.marker{id: 653} + 1*0xd97bd90.marker{id: 670}
SearchResultCell:0xc6ade20.minX{id: 649} == 0 + 2*0xd97b790.marker{id: 648} + -1*0xd97b7c0.marker{id: 653}
SearchResultCell:0xc6ade20.minY{id: 651} == 0 + 2*0xd97b7f0.marker{id: 654} + -0.5*0xd97b820.marker{id: 655}
SearchResultCell:0xc6b2fd0.Height{id: 617} == 200 + 1*0xc6a6a20.marker{id: 625}
SearchResultCell:0xc6b2fd0.Width{id: 614} == 640 + 2*0xc672a00.marker{id: 623} + 1*0xd97bd90.marker{id: 670}
SearchResultCell:0xc6b2fd0.minX{id: 620} == 0 + 2*0xc6a03a0.marker{id: 619} + -1*0xc672a00.marker{id: 623}
SearchResultCell:0xc6b2fd0.minY{id: 621} == 200 + 2*0xc673060.marker{id: 624} + -0.5*0xc6a6a20.marker{id: 625}
UIImageView:0xc67faa0.Height{id: 540} == 150 + 1*0xc6b3380:IB auto generated at build time for view with fixed frame.marker{id: 539}
UIImageView:0xc67faa0.Width{id: 538} == 150 + 1*0xc6b3350:IB auto generated at build time for view with fixed frame.marker{id: 537}
UIImageView:0xc67faa0.minX{id: 534} == 20 + 1*0xc6b32a0:IB auto generated at build time for view with fixed frame.marker{id: 533}
UIImageView:0xc67faa0.minY{id: 536} == 24 + 1*0xc6b3320:IB auto generated at build time for view with fixed frame.marker{id: 535}
UIImageView:0xc696c80.Height{id: 488} == 150 + 1*0xc67ac50:IB auto generated at build time for view with fixed frame.marker{id: 487}
UIImageView:0xc696c80.Width{id: 486} == 150 + 1*0xc67ac20:IB auto generated at build time for view with fixed frame.marker{id: 485}
UIImageView:0xc696c80.minX{id: 482} == 20 + 1*0xc699a30:IB auto generated at build time for view with fixed frame.marker{id: 481}
UIImageView:0xc696c80.minY{id: 484} == 24 + 1*0xc699ab0:IB auto generated at build time for view with fixed frame.marker{id: 483}
UILabel:0xc6732d0.Height{id: 548} == 42 + 1*0xc6b3440:IB auto generated at build time for view with fixed frame.marker{id: 547}
UILabel:0xc6732d0.Width{id: 546} == 434 + 1*0xc6b3410:IB auto generated at build time for view with fixed frame.marker{id: 545}
UILabel:0xc6732d0.minX{id: 542} == 186 + 1*0xc6b33b0:IB auto generated at build time for view with fixed frame.marker{id: 541}
UILabel:0xc6732d0.minY{id: 544} == 20 + 1*0xc6b33e0:IB auto generated at build time for view with fixed frame.marker{id: 543}
UILabel:0xc67bf90.Height{id: 564} == 42 + 1*0xc6b35c0:IB auto generated at build time for view with fixed frame.marker{id: 563}
UILabel:0xc67bf90.Width{id: 562} == 200 + 1*0xc6b3590:IB auto generated at build time for view with fixed frame.marker{id: 561}
UILabel:0xc67bf90.minX{id: 558} == 420 + 1*0xc6b3530:IB auto generated at build time for view with fixed frame.marker{id: 557}
UILabel:0xc67bf90.minY{id: 560} == 68 + 1*0xc6b3560:IB auto generated at build time for view with fixed frame.marker{id: 559}
UILabel:0xc67d490.Height{id: 572} == 42 + 1*0xc6b3680:IB auto generated at build time for view with fixed frame.marker{id: 571}
UILabel:0xc67d490.Width{id: 570} == 200 + 1*0xc6b3650:IB auto generated at build time for view with fixed frame.marker{id: 569}
UILabel:0xc67d490.minX{id: 566} == 186 + 1*0xc6b35f0:IB auto generated at build time for view with fixed frame.marker{id: 565}
UILabel:0xc67d490.minY{id: 568} == 106 + 1*0xc6b3620:IB auto generated at build time for view with fixed frame.marker{id: 567}
UILabel:0xc67d840.Height{id: 512} == 42 + 1*0xc68b930:IB auto generated at build time for view with fixed frame.marker{id: 511}
UILabel:0xc67d840.Width{id: 510} == 200 + 1*0xc68b900:IB auto generated at build time for view with fixed frame.marker{id: 509}
UILabel:0xc67d840.minX{id: 506} == 420 + 1*0xc67d6d0:IB auto generated at build time for view with fixed frame.marker{id: 505}
UILabel:0xc67d840.minY{id: 508} == 68 + 1*0xc68b8d0:IB auto generated at build time for view with fixed frame.marker{id: 507}
UILabel:0xc681210.Height{id: 504} == 42 + 1*0xc67d6a0:IB auto generated at build time for view with fixed frame.marker{id: 503}
UILabel:0xc681210.Width{id: 502} == 200 + 1*0xc67d670:IB auto generated at build time for view with fixed frame.marker{id: 501}
UILabel:0xc681210.minX{id: 498} == 186 + 1*0xc67d610:IB auto generated at build time for view with fixed frame.marker{id: 497}
UILabel:0xc681210.minY{id: 500} == 68 + 1*0xc67d640:IB auto generated at build time for view with fixed frame.marker{id: 499}
UILabel:0xc683e20.Height{id: 520} == 42 + 1*0xc67b5d0:IB auto generated at build time for view with fixed frame.marker{id: 519}
UILabel:0xc683e20.Width{id: 518} == 200 + 1*0xc68b9c0:IB auto generated at build time for view with fixed frame.marker{id: 517}
UILabel:0xc683e20.minX{id: 514} == 186 + 1*0xc68b960:IB auto generated at build time for view with fixed frame.marker{id: 513}
UILabel:0xc683e20.minY{id: 516} == 106 + 1*0xc68b990:IB auto generated at build time for view with fixed frame.marker{id: 515}
UILabel:0xc685a40.Height{id: 556} == 42 + 1*0xc6b3500:IB auto generated at build time for view with fixed frame.marker{id: 555}
UILabel:0xc685a40.Width{id: 554} == 200 + 1*0xc6b34d0:IB auto generated at build time for view with fixed frame.marker{id: 553}
UILabel:0xc685a40.minX{id: 550} == 186 + 1*0xc6b3470:IB auto generated at build time for view with fixed frame.marker{id: 549}
UILabel:0xc685a40.minY{id: 552} == 68 + 1*0xc6b34a0:IB auto generated at build time for view with fixed frame.marker{id: 551}
UILabel:0xc686460.Height{id: 580} == 42 + 1*0xc6b3740:IB auto generated at build time for view with fixed frame.marker{id: 579}
UILabel:0xc686460.Width{id: 578} == 200 + 1*0xc6b3710:IB auto generated at build time for view with fixed frame.marker{id: 577}
UILabel:0xc686460.minX{id: 574} == 420 + 1*0xc6b36b0:IB auto generated at build time for view with fixed frame.marker{id: 573}
UILabel:0xc686460.minY{id: 576} == 106 + 1*0xc6b36e0:IB auto generated at build time for view with fixed frame.marker{id: 575}
UILabel:0xc68a640.Height{id: 528} == 42 + 1*0xc67b690:IB auto generated at build time for view with fixed frame.marker{id: 527}
UILabel:0xc68a640.Width{id: 526} == 200 + 1*0xc67b660:IB auto generated at build time for view with fixed frame.marker{id: 525}
UILabel:0xc68a640.minX{id: 522} == 420 + 1*0xc67b600:IB auto generated at build time for view with fixed frame.marker{id: 521}
UILabel:0xc68a640.minY{id: 524} == 106 + 1*0xc67b630:IB auto generated at build time for view with fixed frame.marker{id: 523}
UILabel:0xc68c5d0.Height{id: 496} == 42 + 1*0xc67d5e0:IB auto generated at build time for view with fixed frame.marker{id: 495}
UILabel:0xc68c5d0.Width{id: 494} == 434 + 1*0xc67ace0:IB auto generated at build time for view with fixed frame.marker{id: 493}
UILabel:0xc68c5d0.minX{id: 490} == 186 + 1*0xc67ac80:IB auto generated at build time for view with fixed frame.marker{id: 489}
UILabel:0xc68c5d0.minY{id: 492} == 20 + 1*0xc67acb0:IB auto generated at build time for view with fixed frame.marker{id: 491}
UILayoutContainerView:0xc670770.Height{id: 393} == 1136 + 1*0xc685240:UIView-Encapsulated-Layout-Height.marker{id: 398}
UILayoutContainerView:0xc670770.Width{id: 390} == 640 + 1*0xc685210:UIView-Encapsulated-Layout-Width.marker{id: 395}
UINavigationTransitionView:0xc6720e0.Height{id: 389} == 1136 + 2*0xc6844d0.marker{id: 394} + 1*0xc685240:UIView-Encapsulated-Layout-Height.marker{id: 398}
UINavigationTransitionView:0xc6720e0.Width{id: 387} == 640 + 2*0xc684430.marker{id: 391} + 1*0xc685210:UIView-Encapsulated-Layout-Width.marker{id: 395}
UINavigationTransitionView:0xc6720e0.minX{id: 386} == 0 + 2*0xc684400.marker{id: 385} + -1*0xc684430.marker{id: 391}
UINavigationTransitionView:0xc6720e0.minY{id: 388} == 0 + 2*0xc6844a0.marker{id: 392} + -1*0xc6844d0.marker{id: 394}
UITableView:0x14a40a00.Height{id: 701} == 0 + 1*_UIParallaxDimmingView:0x1186bb10.Height{id: 707} + 2*0xd97c220.marker{id: 710}
UITableView:0x14a40a00.Width{id: 699} == 640 + 2*0xd97c1c0.marker{id: 703} + 1*0xd9823c0.marker{id: 719} + -2*tempToBeOptimizedToZero{id: 720}
UITableView:0x14a40a00.contentHeight{id: 480} == 400 + 1*0xc6ad9c0.marker{id: 479}
UITableView:0x14a40a00.contentWidth{id: 478} == 640 + 1*0xc6ad980.marker{id: 477}
UITableView:0x14a40a00.minX{id: 698} == 0 + 2*0xd97c190.marker{id: 697} + -1*0xd97c1c0.marker{id: 703}
UITableView:0x14a40a00.minY{id: 700} == 0 + 2*0xd97c1f0.marker{id: 705} + -1*0xd97c220.marker{id: 710}
UITableViewCellContentView:0xc67b900.Height{id: 677} == 199 + 1*0xc6b51c0.marker{id: 683}
UITableViewCellContentView:0xc67b900.Width{id: 675} == 640 + 1*0xc6b5160.marker{id: 678}
UITableViewCellContentView:0xc67b900.minX{id: 674} == 0 + 2*0xc6b5130.marker{id: 673} + -0.5*0xc6b5160.marker{id: 678}
UITableViewCellContentView:0xc67b900.minY{id: 676} == 0 + 2*0xc6b5190.marker{id: 681} + -0.5*0xc6b51c0.marker{id: 683}
UITableViewCellContentView:0xc6a7d10.Height{id: 597} == 199 + 1*0xc6ae810.marker{id: 606}
UITableViewCellContentView:0xc6a7d10.Width{id: 595} == 640 + 1*0xc6ae700.marker{id: 598}
UITableViewCellContentView:0xc6a7d10.minX{id: 594} == 0 + 2*0xc6ae660.marker{id: 593} + -0.5*0xc6ae700.marker{id: 598}
UITableViewCellContentView:0xc6a7d10.minY{id: 596} == 0 + 2*0xc6ae750.marker{id: 605} + -0.5*0xc6ae810.marker{id: 606}
UITableViewCellScrollView:0xc6aeb60.Height{id: 693} == 200 + 1*0xd97b820.marker{id: 655} + 2*0xc6b5c10.marker{id: 706}
UITableViewCellScrollView:0xc6aeb60.Width{id: 691} == 640 + 2*0xd97b7c0.marker{id: 653} + 1*0xd97bd90.marker{id: 670} + 2*0xc6b5bb0.marker{id: 694}
UITableViewCellScrollView:0xc6aeb60.contentHeight{id: 532} == 200 + 1*0xc68c560.marker{id: 531}
UITableViewCellScrollView:0xc6aeb60.contentWidth{id: 530} == 640 + 1*0xc68c4c0.marker{id: 529}
UITableViewCellScrollView:0xc6aeb60.minX{id: 690} == 0 + 2*0xc6b5d00.marker{id: 689} + -1*0xc6b5bb0.marker{id: 694}
UITableViewCellScrollView:0xc6aeb60.minY{id: 692} == 0 + 2*0xc6b5be0.marker{id: 704} + -1*0xc6b5c10.marker{id: 706}
UITableViewCellScrollView:0xc6b3880.Height{id: 613} == 200 + 2*0xc6b2480.marker{id: 618} + 1*0xc6a6a20.marker{id: 625}
UITableViewCellScrollView:0xc6b3880.Width{id: 611} == 640 + 2*0xc6b22e0.marker{id: 615} + 2*0xc672a00.marker{id: 623} + 1*0xd97bd90.marker{id: 670}
UITableViewCellScrollView:0xc6b3880.contentHeight{id: 584} == 200 + 1*0xc6b3ce0.marker{id: 583}
UITableViewCellScrollView:0xc6b3880.contentWidth{id: 582} == 640 + 1*0xc6b37d0.marker{id: 581}
UITableViewCellScrollView:0xc6b3880.minX{id: 610} == 0 + 2*0xc6b2220.marker{id: 609} + -1*0xc6b22e0.marker{id: 615}
UITableViewCellScrollView:0xc6b3880.minY{id: 612} == 0 + 2*0xc6b23b0.marker{id: 616} + -1*0xc6b2480.marker{id: 618}
UITableViewWrapperView:0x1186b2c0.Height{id: 669} == 1136 + 1*0xd97bdf0.marker{id: 686}
UITableViewWrapperView:0x1186b2c0.Width{id: 622} == 640 + 1*0xd97bd90.marker{id: 670}
UITableViewWrapperView:0x1186b2c0.minX{id: 663} == 0 + 2*0xd97bd60.marker{id: 662} + -0.5*0xd97bd90.marker{id: 670}
UITableViewWrapperView:0x1186b2c0.minY{id: 666} == 0 + 2*0xd97bdc0.marker{id: 682} + -0.5*0xd97bdf0.marker{id: 686}
UIView:0xc674820.Height{id: 453} == 1136 + 1*0xc679f40.marker{id: 474}
UIView:0xc674820.Width{id: 451} == 640 + 1*0xc69ff70.marker{id: 470}
UIView:0xc674820.minX{id: 450} == -192 + 2*0xc69ff40.marker{id: 469} + -0.5*0xc69ff70.marker{id: 470}
UIView:0xc674820.minY{id: 452} == 0 + 2*0xc69ffa0.marker{id: 473} + -0.5*0xc679f40.marker{id: 474}
UIView:0xc6752d0.Height{id: 718} == 1136 + 1*0xd982620.marker{id: 730}
UIView:0xc6752d0.Width{id: 716} == 640 + 1*0xd9825c0.marker{id: 722}
UIView:0xc6752d0.minX{id: 715} == 0 + 2*0xd982580.marker{id: 714} + -0.5*0xd9825c0.marker{id: 722}
UIView:0xc6752d0.minY{id: 717} == 0 + 2*0xd9825f0.marker{id: 729} + -0.5*0xd982620.marker{id: 730}
UIViewControllerWrapperView:0xc687700.Height{id: 377} == 1136 + 1*0xc683fa0.marker{id: 382}
UIViewControllerWrapperView:0xc687700.Width{id: 375} == 640 + 1*0xc683f00.marker{id: 378}
UIViewControllerWrapperView:0xc687700.minX{id: 374} == 0 + 2*0xc683ed0.marker{id: 373} + -0.5*0xc683f00.marker{id: 378}
UIViewControllerWrapperView:0xc687700.minY{id: 376} == 0 + 2*0xc683f70.marker{id: 381} + -0.5*0xc683fa0.marker{id: 382}
_UIParallaxDimmingView:0x1186bb10.Width{id: 702} == 640 + 1*0xd9823c0.marker{id: 719}
_UIParallaxDimmingView:0x1186bb10.minX{id: 712} == 0 + 2*0xd982390.marker{id: 711} + -0.5*0xd9823c0.marker{id: 719} + 1*tempToBeOptimizedToZero{id: 720}
_UIParallaxDimmingView:0x1186bb10.minY{id: 713} == 568 + -0.5*_UIParallaxDimmingView:0x1186bb10.Height{id: 707} + 2*0xd9823f0.marker{id: 725}
objective{id: 243} == {objective 0xc67e090: <750:12, 251:1150> + <251:1>*0xc67ace0:IB auto generated at build time for view with fixed frame.marker{id: 493} + <251:1>*0xc67b5d0:IB auto generated at build time for view with fixed frame.marker{id: 519} + <251:1>*0xc67b660:IB auto generated at build time for view with fixed frame.marker{id: 525} + <251:1>*0xc67b690:IB auto generated at build time for view with fixed frame.marker{id: 527} + <750:-1>*0xc67d5e0:IB auto generated at build time for view with fixed frame.marker{id: 495} + <251:1>*0xc67d670:IB auto generated at build time for view with fixed frame.marker{id: 501} + <251:1>*0xc67d6a0:IB auto generated at build time for view with fixed frame.marker{id: 503} + <750:1, 251:1>*0xc67fa30.posErrorMarker{id: 630} + <750:1, 251:1>*0xc685ce0.negError{id: 645} + <750:1, 251:1>*0xc6888b0.negError{id: 659} + <750:1, 251:1>*0xc6888f0.negError{id: 661} + <251:1>*0xc68b900:IB auto generated at build time for view with fixed frame.marker{id: 509} + <251:1>*0xc68b930:IB auto generated at build time for view with fixed frame.marker{id: 511} + <251:1>*0xc68b9c0:IB auto generated at build time for view with fixed frame.marker{id: 517} + <750:1, 251:1>*0xc69ffd0.negError{id: 647} + <750:1, 251:1>*0xc6b3200.negError{id: 629} + <251:1>*0xc6b3410:IB auto generated at build time for view with fixed frame.marker{id: 545} + <750:-1>*0xc6b3440:IB auto generated at build time for view with fixed frame.marker{id: 547} + <251:1>*0xc6b34d0:IB auto generated at build time for view with fixed frame.marker{id: 553} + <251:1>*0xc6b3500:IB auto generated at build time for view with fixed frame.marker{id: 555} + <251:1>*0xc6b3590:IB auto generated at build time for view with fixed frame.marker{id: 561} + <251:1>*0xc6b35c0:IB auto generated at build time for view with fixed frame.marker{id: 563} + <251:1>*0xc6b3650:IB auto generated at build time for view with fixed frame.marker{id: 569} + <251:1>*0xc6b3680:IB auto generated at build time for view with fixed frame.marker{id: 571} + <251:1>*0xc6b3710:IB auto generated at build time for view with fixed frame.marker{id: 577} + <251:1>*0xc6b3740:IB auto generated at build time for view with fixed frame.marker{id: 579} + <750:1, 251:1>*0xc6b45d0.negError{id: 637} + <750:1, 251:1>*0xc6b4620.negError{id: 639} + <750:1, 251:1>*0xc6b4dc0.negError{id: 665} + <750:1, 251:1>*0xc6b4e00.negError{id: 668} + <750:1, 251:1>*0xd9707e0.negError{id: 590} + <750:1, 251:1>*0xd970820.negError{id: 592} + <750:1, 251:1>*0xd974070.negError{id: 586} + <750:1, 251:1>*0xd977ca0.negError{id: 633} + <750:1, 251:1>*0xd977dd0.negError{id: 635} + <750:1, 251:1>*0xd97a6d0.posErrorMarker{id: 587} + <750:1, 251:1>*0xd97ac70.negError{id: 641} + <750:1, 251:1>*0xd97acd0.negError{id: 643} + <750:1, 251:1>*0xd97cfb0.negError{id: 602} + <750:1, 251:1>*0xd97cff0.negError{id: 604}}
tempToBeOptimizedToZeroObjective{id: 728} == {objective 0xda869f0: <1:568> + <1:0.5>*0xd982420.marker{id: 726} + <1:-0.5>*_UIParallaxDimmingView:0x1186bb10.Height{id: 707}}
tempToBeOptimizedToZero{id: 727} == 568 + -0.5*_UIParallaxDimmingView:0x1186bb10.Height{id: 707} + 0.5*0xd982420.marker{id: 726}
Constraints:
<NSAutoresizingMaskLayoutConstraint:0xc672a00 h=-&- v=--& SearchResultCell:0xc6b2fd0.width == UITableViewWrapperView:0x1186b2c0.width> Marker:0xc672a00.marker{id: 623}
<NSAutoresizingMaskLayoutConstraint:0xc673060 h=-&- v=--& SearchResultCell:0xc6b2fd0.midY == + 150> Marker:0xc673060.marker{id: 624}
<NSAutoresizingMaskLayoutConstraint:0xc679f40 h=--& v=--& V:[UIView:0xc674820(568)]> Marker:0xc679f40.marker{id: 474}
<NSAutoresizingMaskLayoutConstraint:0xc683ed0 h=--& v=--& UIViewControllerWrapperView:0xc687700.midX == + 160> Marker:0xc683ed0.marker{id: 373}
<NSAutoresizingMaskLayoutConstraint:0xc683f00 h=--& v=--& H:[UIViewControllerWrapperView:0xc687700(320)]> Marker:0xc683f00.marker{id: 378}
<NSAutoresizingMaskLayoutConstraint:0xc683f70 h=--& v=--& UIViewControllerWrapperView:0xc687700.midY == + 284> Marker:0xc683f70.marker{id: 381}
<NSAutoresizingMaskLayoutConstraint:0xc683fa0 h=--& v=--& V:[UIViewControllerWrapperView:0xc687700(568)]> Marker:0xc683fa0.marker{id: 382}
<NSAutoresizingMaskLayoutConstraint:0xc684400 h=-&- v=-&- UINavigationTransitionView:0xc6720e0.midX == UILayoutContainerView:0xc670770.midX> Marker:0xc684400.marker{id: 385}
<NSAutoresizingMaskLayoutConstraint:0xc684430 h=-&- v=-&- UINavigationTransitionView:0xc6720e0.width == UILayoutContainerView:0xc670770.width> Marker:0xc684430.marker{id: 391}
<NSAutoresizingMaskLayoutConstraint:0xc6844a0 h=-&- v=-&- UINavigationTransitionView:0xc6720e0.midY == UILayoutContainerView:0xc670770.midY> Marker:0xc6844a0.marker{id: 392}
<NSAutoresizingMaskLayoutConstraint:0xc6844d0 h=-&- v=-&- UINavigationTransitionView:0xc6720e0.height == UILayoutContainerView:0xc670770.height> Marker:0xc6844d0.marker{id: 394}
<NSAutoresizingMaskLayoutConstraint:0xc69ff40 h=--& v=--& UIView:0xc674820.midX == + 64> Marker:0xc69ff40.marker{id: 469}
<NSAutoresizingMaskLayoutConstraint:0xc69ff70 h=--& v=--& H:[UIView:0xc674820(320)]> Marker:0xc69ff70.marker{id: 470}
<NSAutoresizingMaskLayoutConstraint:0xc69ffa0 h=--& v=--& UIView:0xc674820.midY == + 284> Marker:0xc69ffa0.marker{id: 473}
<NSAutoresizingMaskLayoutConstraint:0xc6a03a0 h=-&- v=--& SearchResultCell:0xc6b2fd0.midX == UITableViewWrapperView:0x1186b2c0.midX> Marker:0xc6a03a0.marker{id: 619}
<NSAutoresizingMaskLayoutConstraint:0xc6a6a20 h=-&- v=--& V:[SearchResultCell:0xc6b2fd0(100)]> Marker:0xc6a6a20.marker{id: 625}
<NSAutoresizingMaskLayoutConstraint:0xc6ae660 h=--& v=--& UITableViewCellContentView:0xc6a7d10.midX == + 160> Marker:0xc6ae660.marker{id: 593}
and many more log about autoresizing and contentsize
It means your mutable NSSet is changed while enumerating.
OK, After checking your code, you have unsafe code. You are using MyAppDelegate.searchResultArray as datasource of your table. That is the point sometimes causing you crash.
Just think about what if MyAppDelegate.searchResultArray is changed while UITableView is loading?
You should make sure your data source should be static while loading table view. Better set it on the same class which is your ViewController.
I have this problem with NSLayoutConstraint and multiplier in ios 7, ios 8 work perfect.
I m using multipler whit value 0.2 and cause errors!! Alter value multipler for 1 and get size screen in constant value to nslayoutconstraint.
NSLayoutConstraint(item: BT_Facebook, attribute: NSLayoutAttribute.Width, relatedBy: .Equal, toItem: nil, attribute: .Width, multiplier: 0.2 , constant: sizeBtRedeSociais)
Solution is usage size of screen, and not percent.
var sizeBtRedeSociais = UIScreen.mainScreen().bounds.width / 5
var BT_FacebookWidth = NSLayoutConstraint(item: BT_Facebook, attribute: NSLayoutAttribute.Width, relatedBy: .Equal, toItem: nil, attribute: .Width, multiplier: 1, constant: sizeBtRedeSociais)
var BT_TwitterWidth = NSLayoutConstraint(item: BT_Twitter, attribute: NSLayoutAttribute.Width, relatedBy: .Equal, toItem: nil, attribute: .Width, multiplier: 1, constant: sizeBtRedeSociais)
var BT_InstagramWidth = NSLayoutConstraint(item: BT_Instagram, attribute: NSLayoutAttribute.Width, relatedBy: .Equal, toItem: nil, attribute: .Width, multiplier: 1, constant: sizeBtRedeSociais)
var BT_GoogleWidth = NSLayoutConstraint(item: BT_Google, attribute: NSLayoutAttribute.Width, relatedBy: .Equal, toItem: nil, attribute: .Width, multiplier: 1, constant: sizeBtRedeSociais)
var BT_YoutubeWidth = NSLayoutConstraint(item: BT_Youtube, attribute: NSLayoutAttribute.Width, relatedBy: .Equal, toItem: nil, attribute: .Width, multiplier: 1, constant: sizeBtRedeSociais)
Related
in an attempt to create a spreadsheet like table without using UICollectionViews, I decided to use nested UIStackViews.
However, since I am using them in a UITableViewCell, and programmatically create them, I have to remove them from cell, otherwise, when it redraws the cell, the new views will overlap with the old ones.
But when removing them from parent view, it crashes. How to correctly remove nested UIStackViews?
My Code to create nested UIStackViews:
let table = UIStackView()
table.axis = .Vertical
table.spacing = 8
let json = JSON(data: jsonNew)
for i in 0..<json["Rows"].count{
let horizontal = UIStackView()
horizontal.axis = .Horizontal
horizontal.spacing = 8
for j in 0..<json["Rows"][i]["Column"].count{
let label = UILabel()
label.text = json["Rows"][i]["Column"][j].string!
label.lineBreakMode = .ByWordWrapping
label.numberOfLines = 0
label.font = label.font.fontWithSize(12)
horizontal.addArrangedSubview(label)
}
table.addArrangedSubview(horizontal)
}
This is how I remove all views from cell:
for myview in view.subviews{
myview.removeFromSuperview()
}
This is the error:
2016-05-17 11:37:58.745 TestProject[678:26088] _UIConstraintBasedLayoutLogUnsatisfiable is OFF
2016-05-17 11:38:16.563 TestProject[678:26088] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason:
'{objective 0x12faebf00: <1100:16, 760:-6.10352e-05, 750:100, 251:563,
250:-512.5> +
<760:-1>*0x12ddfbd00:UISV-text-width-disambiguation.negError{id:
13416} +
<760:1>*0x12ddfbd00:UISV-text-width-disambiguation.posErrorMarker{id:
13415} +
<760:-1>*0x12ddfbd50:UISV-text-width-disambiguation.negError{id:
13431} +
<760:1>*0x12ddfbd50:UISV-text-width-disambiguation.posErrorMarker{id:
13430} + <750:1, 250:1>*0x12f80df30.negError{id: 13501} + <750:1,
250:1>*0x12f80f000.negError{id: 13499} +
<250:1>*0x12f84df70:UISV-alignment.marker{id: 13578} +
<250:4.6875>*0x12f85ee40:UISV-canvas-connection.marker{id: 13524} +
<750:1, 250:1>*0x12f873b40.posErrorMarker{id: 13486} +
<1100:1>*0x12f8a5730:UIView-Encapsulated-Layout-Width.marker{id:
13587} + <250:-1>*0x12f8b54e0:UISV-alignment.marker{id: 13557} +
<250:-4.6875>*0x12f8d1d70:UISV-canvas-connection.marker{id: 13522} +
<760:-1>*0x12f904f30:UISV-text-width-disambiguation.negError{id:
13412} +
<760:1>*0x12f904f30:UISV-text-width-disambiguation.posErrorMarker{id:
13411} + <760:1>*0x12f904fa0:UISV-spacing.marker{id: 13413} +
<251:-1>*0x12f98e950.marker{id: 12953} +
<251:1>*0x12f9b0580.marker{id: 12949} +
<760:1>*0x12f9cec00:UISV-canvas-connection.marker{id: 13406} +
<250:4.6875>*0x12fa05f30:UISV-spacing.marker{id: 13535} + <999:1,
250:-5.6875>*0x12fa11cd0:UISV-fill-proportionally.negError{id: 13530}
+ <999:1, 250:5.6875>*0x12fa11cd0:UISV-fill-proportionally.posErrorMarker{id:
13529} + <1100:1>*0x12fa146d0.marker{id: 13000} + <750:1,
250:1>*0x12fa27ab0.posErrorMarker{id: 13492} +
<1100:-1>*0x12fa3cc90.marker{id: 12998} + <750:1,
250:1>*0x12fa3cd80.negError{id: 13511} + <750:1,
250:1>*0x12fa3ea20.negError{id: 13513} +
<250:1>*0x12fa47260:UISV-alignment.marker{id: 13572} + <750:1,
251:1>*0x12fa4e480.negError{id: 13020} + <1100:-1,
251:1>*0x12fa55880.marker{id: 14140} +
<250:1>*0x12fa5bc10:UISV-alignment.marker{id: 13581} + <750:1,
250:1>*0x12fa6a5c0.negError{id: 13495} + <750:1,
250:1>*0x12fa711c0.negError{id: 13483} + <994:1,
250:-5.6875>*0x12fa78560:UISV-fill-proportionally.negError{id: 13547}
+ <994:1, 250:5.6875>*0x12fa78560:UISV-fill-proportionally.posErrorMarker{id:
13546} + <250:-1>*0x12fa7c820:UISV-alignment.marker{id: 13565} +
<250:-1>*0x12fa7c870:UISV-alignment.marker{id: 13567} +
<250:1>*0x12fa7c8c0:UISV-alignment.marker{id: 13569} +
<250:1>*0x12fa7f990:UISV-alignment.marker{id: 13575} +
<250:4.6875>*0x12fa7fc20:UISV-spacing.marker{id: 13527} +
<250:4.6875>*0x12fa93c40:UISV-spacing.marker{id: 13531} + <750:1,
250:1>*0x12fa94dd0.negError{id: 13517} + <750:-1,
250:4.6875>*0x12fa980e0:UISV-hiding.marker{id: 13550} +
<250:-1>*0x12fa98d50:UISV-alignment.marker{id: 13559} + <750:1,
250:1>*0x12fa990f0.negError{id: 13505} + <750:-1,
250:4.6875>*0x12faad3d0:UISV-hiding.marker{id: 13551} + <750:1,
251:1>*0x12fab93e0.negError{id: 13022} + <750:1,
250:1>*0x12fac5ee0.negError{id: 13481} +
<250:7>*0x12facbf60:UISV-canvas-connection.marker{id: 13552} + <750:1,
250:1>*0x12fad6cb0.negError{id: 13489} +
<250:4.6875>*0x12fadb570:UISV-spacing.marker{id: 13543} +
<250:1>*0x12fae21d0:UISV-alignment.marker{id: 13584} +
<250:-7>*0x12fae8940:UISV-canvas-connection.marker{id: 13554} +
<750:1, 250:1>*0x12faec7c0.negError{id: 13519} +
<760:-1>*0x12fc0f8a0:UISV-canvas-connection.marker{id: 13403} +
<251:-1>*0x12fc1a8a0.marker{id: 12975} +
<760:1>*0x12fc276f0:UISV-spacing.marker{id: 13409} +
<760:1>*0x12fc54e40:UISV-spacing.marker{id: 13417} +
<760:-1>*0x12fc54e90:UISV-text-width-disambiguation.negError{id:
13429} +
<760:1>*0x12fc54e90:UISV-text-width-disambiguation.posErrorMarker{id:
13428} + <251:-1>*0x12fc6dd10.marker{id: 12972} +
<1100:1>*0x12fc6e830.marker{id: 12969} +
<760:-1>*0x12fc75b80:UISV-text-width-disambiguation.negError{id:
13424} + <760:1>*0x12fc75bf0:UISV-spacing.marker{id: 13425} +
<760:-1>*0x12fc78190:UISV-text-width-disambiguation.negError{id:
13420} +
<760:1>*0x12fc78190:UISV-text-width-disambiguation.posErrorMarker{id:
13419} + <760:1>*0x12fc78200:UISV-spacing.marker{id: 13421} +
<251:-1>*0x12fc8fd20.marker{id: 12957} +
<1100:1>*0x12fc95e90.marker{id: 12963} +
<250:7>*0x12fc960b0.marker{id: 12955} +
<250:4.6875>*0x12fd06e40:UISV-spacing.marker{id: 13533} + <750:1,
250:1>*0x12fd07210.negError{id: 13507} + <996:1,
250:-5.6875>*0x12fd1a3a0:UISV-fill-proportionally.negError{id: 13538}
+ <996:1, 250:5.6875>*0x12fd1a3a0:UISV-fill-proportionally.posErrorMarker{id:
13537} + <995:1,
250:-5.6875>*0x12fd1b3f0:UISV-fill-proportionally.negError{id: 13542}
+ <995:1, 250:5.6875>*0x12fd1b3f0:UISV-fill-proportionally.posErrorMarker{id:
13541} + <250:4.6875>*0x12fd1bd50:UISV-spacing.marker{id: 13539} +
<993:1, 250:-5.6875>*0x12fd1c370:UISV-fill-proportionally.negError{id:
13549} + <993:1,
250:5.6875>*0x12fd1c370:UISV-fill-proportionally.posErrorMarker{id:
13548} + <250:-1>*0x12fd1e670:UISV-alignment.marker{id: 13561} +
<250:-1>*0x12fd1e6c0:UISV-alignment.marker{id: 13563} +
<750:0.00277778>*UILabel:0x12f884240'2016-04-11'.Width{id: 13061} +
<750:0.00277778>*UILabel:0x12fa2f410'2031839'.Width{id: 13031} +
<750:0.00277778>*UILabel:0x12fa2fd90'OTOTAY İÇ VE DIŞ
PAZ.A.Ş.'.Width{id: 13037} +
<750:0.00277778>*UILabel:0x12fa52010'TL'.Width{id: 13055} +
<750:0.00277778>*UILabel:0x12fafa3d0'MAHMUT ÇETİNTÜRK'.Width{id:
13043} + <750:0.00277778>*UILabel:0x12fafa6a0'15000,00'.Width{id:
13049} + <760:0>*UIStackView:0x12fa081c0.Width{id: 13152} + <760:0,
750:-0.00277778>*UIStackView:0x12fb2b740.Width{id: 13067} +
<760:0>*UIStackView:0x12fc44970.Width{id: 13322} +
<760:0>*UIStackView:0x12fc65df0.Width{id: 13237}}: internal error.
Setting empty vector for variable
UILabel:0x12f905720'6955677'.Width{id: 13371}.'
* First throw call stack:
(0x18221ae38 0x18187ff80 0x18221ad80 0x182b52de0 0x182ccf4d4 0x182b4fcc8 0x182b53108 0x182b50d18 0x182b53928 0x182b585e4
0x182b4d010 0x182b4cd78 0x187464c80 0x187357368 0x187356c1c
0x182b4cd50 0x187356ac4 0x1876702c4 0x1873554e8 0x100143634
0x100148164 0x1876b2f40 0x1876b3120 0x1876b6a2c 0x1874a9500
0x1874a923c 0x1874a8ebc 0x187448aa0 0x1876a1a34 0x1876b7b74
0x1874487ac 0x1873580e4 0x184cfea28 0x184cf9634 0x184cf94f4
0x184cf8b24 0x184cf886c 0x184cf1dd8 0x1821d07b0 0x1821ce554
0x1821ce984 0x1820f8d10 0x1839e0088 0x1873c5f70 0x100107234
0x181c968b8)
libc++abi.dylib: terminating with uncaught exception of type NSException
The problem is due the insidestackview, this one will grow in height variably and the problem is when you scroll down or change the view, and the cells needs to be reused and the other Label content height will be different from the one who is trying to reuse.
The solution may depends what are your needs, but if you want to keep
label.numberOfLines = 0 and label.lineBreakMode = .ByWordWrapping (grow stackview to wrap as many lines as necessary)
You can play with the distribution and Heights and multipliers > 0 in your constraints. So it can be .equalSpacing or if you have a max-height for any of that you can use .fill (which is the default):
Option1:
stack.distribution = .equalSpacing
Option2:
NSLayoutConstraint(item: outsideStackView, attribute: .top, relatedBy: .equal, toItem: parentView, attribute: .bottom, multiplier: 2, constant: 20)
Option3: Give a MaxHeight to inside stackview
Option4: Remove...
label.lineBreakMode = .ByWordWrapping
label.numberOfLines = 0
You need to remove the view from the stackView with removeArrangedSubview, i.e.
for myview in view.subviews{
table.removeArrangedSubview(myview)
myview.removeFromSuperview()
}
UIStackView is a non-rendering UIView which automatically adds subviews to its view heirachy when calling addArrangedSubview, so you don't need to call addSubview. When removing an arrangedSubview, you must call stackView.removeArrangedSubview(view) and view.removeFromSuperview()
I developed an app using a iOS 9 device for testing and everything is fine, but I need the compatibility with iOS 7 also.
At the start I load a view controller with some buttons, one of them should present modally another controller but on iOS 7 device I get a very weird crash:
Objective: {objective 0x165f98c0: <> +
<750:-6.61817e-08>*0x16569cd0.negError{id: 118} +
<999:2>*0x16569ec0.negError{id: 175} + <999:2>0x16570520.negError{id:
172} + <999:1>_UILayoutGuide:0x1655a6c0.Width{id: 176} +
<999:1>*_UILayoutGuide:0x165a3c70.Width{id: 173}} 2016-04-27
15:38:07.483 191PerTe[502:60b] *** Terminating app due to uncaught
exception 'NSInternalInconsistencyException', reason: '{ Rows: 0x16569ec0.posErrorMarker{id: 174} == 0 +
1*0x16569ec0.negError{id: 175} + 1*_UILayoutGuide:0x1655a6c0.Width{id:
176} 0x16570520.posErrorMarker{id: 171} == 0 +
1*0x16570520.negError{id: 172} + 1*_UILayoutGuide:0x165a3c70.Width{id:
173} UITransitionView:0x165a21d0.Height{id: 159} == 960 +
1*0x165f11b0.marker{id: 150} + 2*0x1655ed20.marker{id: 168}
UITransitionView:0x165a21d0.Width{id: 154} == 640 +
1*0x1655f650.marker{id: 164} UITransitionView:0x165a21d0.minX{id:
162} == 0 + 2*0x1658f790.marker{id: 161} + -0.5*0x1655f650.marker{id:
164} UITransitionView:0x165a21d0.minY{id: 163} == 0 +
2*0x1655f080.marker{id: 167} + -1*0x1655ed20.marker{id: 168}
UIView:0x1659fb60.Height{id: 185} == 960 + 1*0x165f11b0.marker{id:
150} + 2*0x1655ed20.marker{id: 168} + 2*0x16559660.marker{id: 194}
UIView:0x1659fb60.Width{id: 188} == 640 + 1*0x1655f650.marker{id:
164} + 2*0x1656b160.marker{id: 190} UIView:0x1659fb60.minX{id: 187}
== 0 + 2*0x165596b0.marker{id: 186} + -1*0x1656b160.marker{id: 190} UIView:0x1659fb60.minY{id: 189} == 0 + 2*0x1656b190.marker{id: 193} +
-1*0x16559660.marker{id: 194} UIWindow:0x165a6fe0.Height{id: 141} == 960 + 1*0x165f11b0.marker{id: 150} UIWindow:0x165a6fe0.Width{id: 136}
== 640 + 1*0x165ae3a0.marker{id: 147} UIWindow:0x165a6fe0.minX{id: 144} == 0 + 2*0x16588c90.marker{id: 143} + -0.5*0x165ae3a0.marker{id:
147} UIWindow:0x165a6fe0.minY{id: 146} == 0 + 2*0x165f4e20.marker{id:
145} + -0.5*0x165f11b0.marker{id: 150}
_UILayoutGuide:0x1655a6c0.Height{id: 182} == 0 +
1*0x1656c6a0.marker{id: 181} _UILayoutGuide:0x1655a6c0.minY{id: 184}
== 960 + 1*0x165f11b0.marker{id: 150} + 2*0x1655ed20.marker{id: 168} + -1*0x1656c6a0.marker{id: 181} + 1*0x1656b5f0.marker{id: 183} + 2*0x16559660.marker{id: 194} _UILayoutGuide:0x165a3c70.Height{id:
178} == 40 + 1*0x1656af20.marker{id: 177}
_UILayoutGuide:0x165a3c70.minY{id: 180} == 0 +
1*0x165676a0.marker{id: 179} objective{id: 1} == {objective
0x165f98c0: <> + <750:-6.61817e-08>*0x16569cd0.negError{id: 118} +
<999:2>*0x16569ec0.negError{id: 175} + <999:2>0x16570520.negError{id:
172} + <999:1>_UILayoutGuide:0x1655a6c0.Width{id: 176} +
<999:1>*_UILayoutGuide:0x165a3c70.Width{id: 173}}
Constraints: Marker:0x16559660.marker{id: 194}
Marker:0x165596b0.marker{id: 186}
(Integralization adjustment:3.20747e-06)
Marker:0x1655ed20.marker{id: 168}
Marker:0x1655f080.marker{id: 167}
Marker:0x1655f650.marker{id:
164} Marker:0x1656b160.marker{id: 190}
(Integralization adjustment:6.41495e-06)
Marker:0x1656b190.marker{id: 193}
Marker:0x1658f790.marker{id: 161}
Marker:0x165ae3a0.marker{id: 147}
Marker:0x165f11b0.marker{id: 150}
<_UILayoutSupportConstraint:0x165676a0
V:|-(0)-[_UILayoutGuide:0x165a3c70] (Names: '|':UIView:0x1659fb60
)> Marker:0x165676a0.marker{id: 179}
<_UILayoutSupportConstraint:0x16569ec0
H:[_UILayoutGuide:0x1655a6c0(0#999)]
priority:999> Marker:0x16569ec0.posErrorMarker{id: 174}
<_UILayoutSupportConstraint:0x1656af20
V:[_UILayoutGuide:0x165a3c70(20)]> Marker:0x1656af20.marker{id: 177}
<_UILayoutSupportConstraint:0x1656b5f0
_UILayoutGuide:0x1655a6c0.bottom == UIView:0x1659fb60.bottom> Marker:0x1656b5f0.marker{id: 183}
<_UILayoutSupportConstraint:0x1656c6a0
V:[_UILayoutGuide:0x1655a6c0(0)]> Marker:0x1656c6a0.marker{id: 181}
<_UILayoutSupportConstraint:0x16570520
H:[_UILayoutGuide:0x165a3c70(0#999)]
priority:999> Marker:0x16570520.posErrorMarker{id: 171}
<_UIWindowAnchoringConstraint:0x16588c90 h=--- v=---
UIWindow:0x165a6fe0.midX == + 160> Marker:0x16588c90.marker{id: 143}
<_UIWindowAnchoringConstraint:0x165f4e20 h=--- v=---
UIWindow:0x165a6fe0.midY == + 240> Marker:0x165f4e20.marker{id: 145}
Integralization Adjustments: 0x165596b0.marker{id: 186}
[] ->
0.000003 0x1656b160.marker{id: 190} [] ->
0.000006
Statistics: 18 rows. Variable counts:
1 -> 6
2 -> 10
3 -> 1
5 -> 1 }: internal error. Cannot find an outgoing row head for incoming head 0x16569cd0.negError{id: 118}, which should never
happen.'
*** First throw call stack: (0x2f3cef83 0x39b7fccf 0x2f3ceec5 0x2fd3a315 0x2fd39e57 0x2fd35b95 0x31beacd3 0x31e832ab 0x31be9bc1
0x31d02f4f 0x31c23d57 0x31c23c73 0x31870111 0x3a06781f 0x3a067777
0x2f3998a1 0x2f398175 0x2f302ebf 0x2f302ca3 0x34208663 0x31c4f14d
0x28f3f 0x3a08cab7) libc++abi.dylib: terminating with uncaught
exception of type NSException (lldb)
I already tried to:
disable size classes
reset all constraints on the other controller, present modally a blank view controller
obviously everything is working on iOS 8/9
Some advice?
for some reason i have a dispatch_async thread, and it crashes unless i have a NSLog() method executed in front of it. the block runs a method that retrieves a username from a database.
crash:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
user_web_communicator *usrWeb = [[user_web_communicator alloc]init];
NSString *author = [usrWeb getUsernameFromID:author_string];
[_author_label setText:[NSString stringWithFormat:#"Author: %#",author]];
});
working:
NSLog(#"Fetching author for id: %#",author_string);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
user_web_communicator *usrWeb = [[user_web_communicator alloc]init];
NSString *author = [usrWeb getUsernameFromID:author_string];
[_author_label setText:[NSString stringWithFormat:#"Author: %#",author]];
});
error
2013-08-19 13:56:06.149 Poll Me[4995:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '{
Rows: AsyncImageView:0x827aa00.minX == 10 + 1*0x827b8d0.marker +
-1*0x8281210.marker + 0.5*0x8281260.marker AsyncImageView:0x827aa00.minY == 27.5 + -1*0x827b910.marker +
-1*0x82812a0.marker + 0.5*0x82812e0.marker + 0.5*0x82823f0.marker + -0.5*AsyncImageView:0x827aa00.Height Regular_Cell:0x827a400.Height == 56 + 1*0x82823f0.marker Regular_Cell:0x827a400.Width == 320 +
1*0x8281ee0.marker Regular_Cell:0x827a400.minX == 0 +
1*0x8281740.marker + -0.5*0x8281ee0.marker
Regular_Cell:0x827a400.minY == 46 + 1*0x8281b30.marker +
-0.5*0x82823f0.marker UILabel:0x827a8e0.Width == 0 + 1*0x827b730.marker + 1*0x827b790.marker + -1*0x827b7d0.marker +
1*UILabel:0x827adc0.Width UILabel:0x827a8e0.minX == 18 +
1*0x827b7d0.marker + 1*0x827b8d0.marker + -1*0x8281210.marker +
0.5*0x8281260.marker + 1*AsyncImageView:0x827aa00.Width UILabel:0x827a8e0.minY == 19.5 + -1*0x827b810.marker +
1*0x827b890.marker + -1*0x827b910.marker + -1*0x82812a0.marker +
0.5*0x82812e0.marker + 0.5*0x82823f0.marker + 0.5*AsyncImageView:0x827aa00.Height + -1*UILabel:0x827a8e0.Height + -1*UILabel:0x827b140.Height UILabel:0x827adc0.minX == 18 + 1*0x827b730.marker + 1*0x827b8d0.marker + -1*0x8281210.marker +
0.5*0x8281260.marker + 1*AsyncImageView:0x827aa00.Width UILabel:0x827adc0.minY == 20.5 + 1*0x827b6f0.marker +
-1*0x82812a0.marker + 0.5*0x82812e0.marker UILabel:0x827b140.minX == 18 + 1*0x827b850.marker + 1*0x827b8d0.marker + -1*0x8281210.marker +
0.5*0x8281260.marker + 1*AsyncImageView:0x827aa00.Width UILabel:0x827b140.minY == 27.5 + 1*0x827b890.marker +
-1*0x827b910.marker + -1*0x82812a0.marker + 0.5*0x82812e0.marker + 0.5*0x82823f0.marker + 0.5*AsyncImageView:0x827aa00.Height + -1*UILabel:0x827b140.Height UITableViewCellContentView:0x827a560.Height == 55 +
1*0x82812e0.marker UITableViewCellContentView:0x827a560.Width == 300
+ 1*0x8281260.marker UITableViewCellContentView:0x827a560.minX == 0 + 1*0x8281210.marker + -0.5*0x8281260.marker
UITableViewCellContentView:0x827a560.minY == 0.5 + 1*0x82812a0.marker
+ -0.5*0x82812e0.marker objective == <> + <750:-1>*0x8280fc0.negError + <250:-1>*0x8280fc0.posErrorMarker + <750:-1>*0x8281030.negError + <250:-1>*0x8281030.posErrorMarker
Constraints: Marker:0x8281210.marker
Marker:0x8281260.marker
Marker:0x82812a0.marker (Integralization adjustment:0.5) Marker:0x82812e0.marker
Marker:0x8281740.marker
Marker:0x8281b30.marker
Marker:0x8280fc0.posErrorMarker
Marker:0x8281030.posErrorMarker
Marker:0x827b6f0.marker
Marker:0x827b730.marker
Marker:0x827b790.marker
Marker:0x827b7d0.marker
Marker:0x827b810.marker
Marker:0x827b850.marker
Marker:0x827b890.marker
Marker:0x827b8d0.marker
Marker:0x827b910.marker
Marker:0x8281ee0.marker
Marker:0x82823f0.marker }: internal
error. Cannot find an outgoing row head for incoming head
0x8280fc0.negError, which should never happen.'
* First throw call stack: (0x195d012 0x166ae7e 0x195cdeb 0xefef89 0xf01fcf 0xf025c7 0xf0d58f 0xf0d6d4 0x7d860a 0x7e02af 0x7e03be
0x2e7601 0x49484e 0x354ced 0x2e940c 0x354a7b 0x359919 0x3599cf
0x3421bb 0x352b4b 0x2ef2dd 0x167e6b0 0x17dfc0 0x17233c 0x172150
0xf00bc 0xf1227 0xf18e2 0x1925afe 0x1925a3d 0x19037c2 0x1902f44
0x1902e1b 0x29be7e3 0x29be668 0x29effc 0x1e5ed 0x1d75) 2013-08-19
13:56:06.149 Poll Me[4995:4f03] * Terminating app due to uncaught
exception 'NSInternalInconsistencyException', reason: '{ Rows:
AsyncImageView:0x827aa00.minX == 10 + 1*0x827b8d0.marker +
-1*0x8281210.marker + 0.5*0x8281260.marker AsyncImageView:0x827aa00.minY == 27.5 + -1*0x827b910.marker +
-1*0x82812a0.marker + 0.5*0x82812e0.marker + 0.5*0x82823f0.marker + -0.5*AsyncImageView:0x827aa00.Height Regular_Cell:0x827a400.Height == 56 + 1*0x82823f0.marker Regular_Cell:0x827a400.Width == 320 +
1*0x8281ee0.marker Regular_Cell:0x827a400.minX == 0 +
1*0x8281740.marker + -0.5*0x8281ee0.marker
Regular_Cell:0x827a400.minY == 46 + 1*0x8281b30.marker +
-0.5*0x82823f0.marker UILabel:0x827a8e0.Width == 0 + 1*0x827b730.marker + 1*0x827b790.marker + -1*0x827b7d0.marker +
1*UILabel:0x827adc0.Width UILabel:0x827a8e0.minX == 18 +
1*0x827b7d0.marker + 1*0x827b8d0.marker + -1*0x8281210.marker +
0.5*0x8281260.marker + 1*AsyncImageView:0x827aa00.Width UILabel:0x827a8e0.minY == 19.5 + -1*0x827b810.marker +
1*0x827b890.marker + -1*0x827b910.marker + -1*0x82812a0.marker +
0.5*0x82812e0.marker + 0.5*0x82823f0.marker + 0.5*AsyncImageView:0x827aa00.Height + -1*UILabel:0x827a8e0.Height + -1*UILabel:0x827b140.Height UILabel:0x827adc0.minX == 18 + 1*0x827b730.marker + 1*0x827b8d0.marker + -1*0x8281210.marker +
0.5*0x8281260.marker + 1*AsyncImageView:0x827aa00.Width UILabel:0x827adc0.minY == 20.5 + 1*0x827b6f0.marker +
-1*0x82812a0.marker + 0.5*0x82812e0.marker UILabel:0x827b140.minX == 18 + 1*0x827b850.marker + 1*0x827b8d0.marker + -1*0x8281210.marker +
0.5*0x8281260.marker + 1*AsyncImageView:0x827aa00.Width UILabel:0x827b140.minY == 27.5 + 1*0x827b890.marker +
-1*0x827b910.marker + -1*0x82812a0.marker + 0.5*0x82812e0.marker + 0.5*0x82823f0.marker + 0.5*AsyncImageView:0x827aa00.Height + -1*UILabel:0x827b140.Height UITableViewCellContentView:0x827a560.Height == 55 +
1*0x82812e0.marker UITableViewCellContentView:0x827a560.Width == 300
+ 1*0x8281260.marker UITableViewCellContentView:0xlibc++abi.dylib: terminate called throwing an exception827a560.minX == 0 +
1*0x8281210.marker + -0.5*0x8281260.marker
UITableViewCellContentView:0x827a560.minY == 0.5 + 1*0x82812a0.marker
+ -0.5*0x82812e0.marker objective == <> + <750:-1>*0x8280fc0.negError + <250:-1>*0x8280fc0.posErrorMarker + <750:-1>*0x8281030.negError + <250:-1>*0x8281030.posErrorMarker
Constraints: Marker:0x8281210.marker
Marker:0x8281260.marker
Marker:0x82812a0.marker (Integralization adjustment:0.5) Marker:0x82812e0.marker
Marker:0x8281740.marker Marker:0x8281b30.marker
Marker:0x8280fc0.posErrorMarker
Marker:0x8281030.posErrorMarker
Marker:0x827b6f0.marker
Marker:0x827b730.marker
Marker:0x827b790.marker
Marker:0x827b7d0.marker
Marker:0x827b810.marker
Marker:0x827b850.marker
Marker:0x827b890.marker
Marker:0x827b8d0.marker
Marker:0x827b910.marker
Marker:0x8281ee0.marker
Marker:0x82823f0.marker }: internal
error. Cannot find an outgoing row head for incoming head
0x8280fc0.negError, which should never happen.'
* First throw call stack: (0x195d012 0x166ae7e 0x195cdeb 0xefef89 0xf01fcf 0xf020d3 0x7d86dc 0x7d9280 0x7dd4a3 0x3f7e3c 0x3f8022
0x3f8064 0x2f33b 0x277553f 0x2787014 0x27782e8 0x2778450 0x92710e72
0x926f8d2a) (lldb)
can you please tell me why this could be happening? i dont want to keep the NSLog() there because it runs it several times and gets in the way when trying to read output. Thank you in advance =)
It is undefined behavior to set the text property of a label in a background thread, or any other UI changes for that matter. Since it is undefined behavior I can not explain why it works with the NSLog but you need to dispatch setting the label's text to the main thread.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
user_web_communicator *usrWeb = [[user_web_communicator alloc]init];
NSString *author = [usrWeb getUsernameFromID:author_string];
dispatch_sync(dispatch_get_main_queue(), ^{
[_author_label setText:[NSString stringWithFormat:#"Author: %#",author]];
})
});
The crash log is below.
Do you know any particular reason why might [UIScrollView removeFromSuperview] can crash? The scrollview contains view hierarchy with different types of UIViews. I also finds that the ad hoc version crash often not the debug version. I could not find any reason for that.
Same viewcontroller is loaded in a different flow in iPhone that works fine. But in iPad it crashes.
In iPad, in a container view controller, only viewcontroler.view is loaded.
Incident Identifier: EE102239-34D1-4BE7-8B52-41F74AB26203
CrashReporter Key: 2b11ea2a01ac5618e199ffc5a1e1f321600bb6a9
Hardware Model: iPad3,4
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2013-06-18 15:19:16.132 +0200
OS Version: iOS 6.1.3 (10B329)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000000
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x3bab7070 prepareForMethodLookup + 20
1 libobjc.A.dylib 0x3bab6fb2 lookUpMethod + 42
2 libobjc.A.dylib 0x3bab6f7e _class_lookupMethodAndLoadCache3 + 14
3 libobjc.A.dylib 0x3bab6638 objc_msgSend_uncached + 24
4 QuartzCore 0x357f2a72 CA::Layer::contents_visibility_changed(CA::Transaction*, bool) + 50
5 QuartzCore 0x357f29de CA::Layer::mark_visible(CA::Transaction*, bool) + 190
6 QuartzCore 0x357f29b2 CA::Layer::mark_visible(CA::Transaction*, bool) + 146
7 QuartzCore 0x357f29b2 CA::Layer::mark_visible(CA::Transaction*, bool) + 146
8 QuartzCore 0x357f29b2 CA::Layer::mark_visible(CA::Transaction*, bool) + 146
9 QuartzCore 0x357f29b2 CA::Layer::mark_visible(CA::Transaction*, bool) + 146
10 QuartzCore 0x357f28d2 CA::Layer::update_removed_sublayer(CA::Transaction*, unsigned int) + 18
11 QuartzCore 0x357f255a CA::Layer::remove_sublayer(CA::Transaction*, CALayer*) + 130
12 QuartzCore 0x357f246a CA::Layer::remove_from_superlayer() + 34
13 UIKit 0x35a6e92c -[UIView(Hierarchy) removeFromSuperview] + 144
14 UIKit 0x35b857bc -[UIScrollView removeFromSuperview] + 60
15 MyApp 0x000bde8a -[iPadNavigationController vcAnimationDone] (iPadNavigationController.m:400)
16 UIKit 0x35a55ab6 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 154
17 UIKit 0x35aca8f8 -[UIViewAnimationState animationDidStop:finished:] + 44
18 QuartzCore 0x35801304 CA::Layer::run_animation_callbacks(void*) + 204
19 libdispatch.dylib 0x3bed55d8 _dispatch_client_callout + 20
20 libdispatch.dylib 0x3bed8e40 _dispatch_main_queue_callback_4CF + 224
21 CoreFoundation 0x33c051ac __CFRunLoopRun + 1284
22 CoreFoundation 0x33b78238 CFRunLoopRunSpecific + 352
23 CoreFoundation 0x33b780c4 CFRunLoopRunInMode + 100
24 GraphicsServices 0x37733336 GSEventRunModal + 70
25 UIKit 0x35a942b4 UIApplicationMain + 1116
A few line from the code (as asked),
previous = showing;
showing = [ vc retain ];
showing.view.frame = startFrameIn;
[ container addSubview:showing.view ];
CGContextRef context = UIGraphicsGetCurrentContext();
[ UIView beginAnimations:nil context:context ];
[ UIView setAnimationDelegate:self ];
[ UIView setAnimationDidStopSelector:#selector(vcAnimationDone) ];
[ UIView setAnimationCurve:UIViewAnimationCurveEaseOut ];
[ UIView setAnimationDuration:0.4 ];
previous.view.frame = endFrameOut;
showing.view.frame = detailFrame;
[ UIView commitAnimations ];
}
- (void) vcAnimationDone {
if ( previous != nil ) {
if (previous.view.superview != nil) {
[previous.view removeFromSuperview];
}
[ previous release ];
previous = nil;
}
A very probable reason is that you are overreleasing your scrollview or one of the views inside it.
Calling removeFromSuperview then deallocates the view instead of simply decreasing the retain count.
Actually, if you are still stuck with non-ARC project, Static Code Analysis is very useful for this kind of bug. Retain/release balancing issues are hard to pin down, and nearly impossible with incomplete method so I suggest you post the full method body if possible.
Thanks everyone for your answers, tips and tricks. However one thing I want share with you is the cause of the crash. I found that the crash was at different thread in different times. I had several views loaded with button pressing/menu in my iPad app. Some of the button pressing fetch data from web service. So I was bit confused to get the cuase of crash, animation, or url connection etc... I tried with enabled NSZombie objects, but it did not show any information.
Then I tried with Guard Malloc. This only runs in Simulator. And magically I found the code point of crash. I have function to convert a hex string into data. There I have line of code to make a C string null terminated. where I assigned 0 at the last index. and that makes the crash!
tmpCh[count] = 0;
I do not why, but probably it takes some time in the memory management procedure in iOS so it crash at different thread at different times. But with Guard malloc in Simulator, it always point out here and when I rewrite the code, the crash is gone.
/* Converts a hex string to bytes.
Precondition:
. The hex string can be separated by space or not.
. the string length without space or 0x, must be even. 2 symbols for one byte/char
. sample input: 23 3A F1 OR 233AF1
*/
+ (NSData *) dataFromHexString:(NSString*)hexString
{
if (hexString.length < 1) {
return nil;
}
char * tmpCh = (char *) malloc([hexString length] * sizeof(char));
int count = 0;
for (int k=0; k<hexString.length;k++) {
char c = [hexString characterAtIndex:k];
if (c == (char)0x20) { //skip space
continue;
}
if (c == '0') { // skip 0x
if(k+1 < hexString.length){
if ([hexString characterAtIndex:k+1] == 'x'
|| [hexString characterAtIndex:k+1] == 'X' )
{
k = k + 1;
continue;
}
}
}
tmpCh[count] = c;
count++;
}
tmpCh[count] = 0; // make null terminated string
if (count % 2) {
return nil;
}
NSString *temp = [[NSString alloc] initWithUTF8String:tmpCh];
free(tmpCh);
if ([temp length] % 2 != 0) {
return nil;
}
NSMutableData *result = [[NSMutableData alloc] init];
unsigned char byte;
char hexChars[3] = {0};
for (int i=0; i < (temp.length/2); i++) {
hexChars[0] = [temp characterAtIndex:i*2];
hexChars[1] = [temp characterAtIndex:i*2+1];
if (![Util isValidChar:hexChars[0]] || ![Util isValidChar:hexChars[1]]) {
return nil;
}
byte = strtol(hexChars, NULL, 16);
[result appendBytes:&byte length:1];
}
NSData * data = [NSData dataWithData:result];
[result release];
return data;
}
I'm new to ios development and to stackoverflow. I did try searching both stackoverflow and google before posting.
I built a simple little app, originally just left it an iphone only app, but decided to make it universal in the end. I, stupidly, was messing around when i was getting to know xcode 4 and switched it to universal and then back again so i had to recopy the project and do it again. This time i started it with a universal app. (Not when i created it but after i went to project and selected it there) It created the ipad folder and mainwindow-ipad.xib file but was empty of course since i didn't do anything yet. I had it set up as a tabbed based app so my iphone version had firstview and secondview nib files also, but the ipad version didn't. I set it all up in iphone version first and it worked fine. I then went and laid down the ipad version (i did eliminate the second tab from mainwindow-ipad because i didn't need it)
i then went and created a new nib file and placed it in the ipad folder along with "main-ipad.h" and "main-ipad.m". I copied my code and connected everything and it runs fine on ipad simulator but now when i try and run iphone simulator i get "SIGABRT error. I took a screen shot of it. I don't fully understand objective-c so i was hoping someone can help me? I can post any code or whatever you might need to help me with this error so just ask.
Appreciate any help and suggestions you may have!
Thanks!
[Okay i would have posted image but I can't since I'm a new user, instead i posted the line highlighted and the output from xcode]
Code for file with error:
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil); //ERROR IS ON THIS LINE <-----
[pool release];
return retVal;
}
[OUTPUT]
2011-06-18 17:32:43.980 Price Assist[445:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x4e09cc0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key finallabel.'
*** Call stack at first throw:
(
0 CoreFoundation 0x00dc35a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f17313 objc_exception_throw + 44
2 CoreFoundation 0x00dc34e1 -[NSException raise] + 17
3 Foundation 0x00795677 _NSSetUsingKeyValueSetter + 135
4 Foundation 0x007955e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
5 UIKit 0x0021130c -[UIRuntimeOutletConnection connect] + 112
6 CoreFoundation 0x00d398cf -[NSArray makeObjectsPerformSelector:] + 239
7 UIKit 0x0020fd23 -[UINib instantiateWithOwner:options:] + 1041
8 UIKit 0x00211ab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
9 UIKit 0x000c7628 -[UIViewController _loadViewFromNibNamed:bundle:] + 70
10 UIKit 0x000c5134 -[UIViewController loadView] + 120
11 UIKit 0x000c500e -[UIViewController view] + 56
12 UIKit 0x00038d42 -[UIWindow addRootViewControllerViewIfPossible] + 51
13 Foundation 0x007955e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
14 UIKit 0x00048ff6 -[UIView(CALayerDelegate) setValue:forKey:] + 173
15 UIKit 0x0021130c -[UIRuntimeOutletConnection connect] + 112
16 CoreFoundation 0x00d398cf -[NSArray makeObjectsPerformSelector:] + 239
17 UIKit 0x0020fd23 -[UINib instantiateWithOwner:options:] + 1041
18 UIKit 0x00211ab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
19 UIKit 0x0001717a -[UIApplication _loadMainNibFile] + 172
20 UIKit 0x00017cf4 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 291
21 UIKit 0x00022617 -[UIApplication handleEvent:withNewEvent:] + 1533
22 UIKit 0x0001aabf -[UIApplication sendEvent:] + 71
23 UIKit 0x0001ff2e _UIApplicationHandleEvent + 7576
24 GraphicsServices 0x00ffc992 PurpleEventCallback + 1550
25 CoreFoundation 0x00da4944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
26 CoreFoundation 0x00d04cf7 __CFRunLoopDoSource1 + 215
27 CoreFoundation 0x00d01f83 __CFRunLoopRun + 979
28 CoreFoundation 0x00d01840 CFRunLoopRunSpecific + 208
29 CoreFoundation 0x00d01761 CFRunLoopRunInMode + 97
30 UIKit 0x000177d2 -[UIApplication _run] + 623
31 UIKit 0x00023c93 UIApplicationMain + 1160
32 Price Assist 0x000029a9 main + 121
33 Price Assist 0x00002925 start + 53
)
terminate called after throwing an instance of 'NSException'
iPhone FirstView nib file .h code:
#interface FirstViewController : UIViewController {
IBOutlet UITextField *dollarinput;
IBOutlet UITextField *centsinput;
IBOutlet UIButton *combinevalue;
IBOutlet UITextField *percentoffinput;
IBOutlet UILabel *discountlabel;
IBOutlet UILabel *finallabel;
}
- (IBAction)calculate:(id)sender;
- (IBAction)backgroundTouched:(id)sender;
- (IBAction)autonext:(id)sender;
iPhone FirstView nib file .m code:
//
// FirstViewController.m
// Price Assist
//
// Created by Dustin Schreiber on 6/15/11.
// Copyright 2011 TheTechSphere.com. All rights reserved.
//
#import "FirstViewController.h"
#implementation FirstViewController
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
}
*/
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc. that aren't in use.
}
- (void)viewDidUnload
{
[percentoffinput release];
percentoffinput = nil;
[discountlabel release];
discountlabel = nil;
[finallabel release];
finallabel = nil;
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc
{
[percentoffinput release];
[discountlabel release];
[finallabel release];
[super dealloc];
}
- (IBAction)calculate:(id)sender {
if ([centsinput.text length] == 0){
centsinput.text = #"00";
}
if ([dollarinput.text length] == 0){
dollarinput.text = #"00";
}
if ([percentoffinput.text length] == 0){
percentoffinput.text = #"00";
}
double cDollars = [dollarinput.text doubleValue];
double cCents = [centsinput.text doubleValue];
double percentoff = [percentoffinput.text doubleValue] / 100;
NSString *ccDollars = [[NSNumber numberWithFloat:cDollars] stringValue];
NSString *ccCents = [[NSNumber numberWithFloat:cCents] stringValue];
NSString *placeholder = [NSString stringWithFormat:#"%#.%#", ccDollars, ccCents];
double combined = [placeholder doubleValue];
double discount = combined * percentoff;
NSString *discountholder2 =[NSString stringWithFormat:#"%.2f", discount];
discountlabel.text = discountholder2;
double newprice = (combined - discount);
NSString *str = [NSString stringWithFormat:#"%.2f", newprice];
finallabel.text = str;
dollarinput.text = ccDollars;
centsinput.text = ccCents;
percentoffinput.text = [[NSNumber numberWithFloat:percentoff] stringValue];
}
-(IBAction)backgroundTouched:(id)sender
{
[dollarinput resignFirstResponder];
[centsinput resignFirstResponder];
[percentoffinput resignFirstResponder];
}
- (IBAction)autonext:(id)sender {
if ([centsinput.text length ] >= 2) {
if ([centsinput.text length] > 2) {
centsinput.text = #"";
} else {
//next field
}
}
}
#end
Thanks again! If anyone has any suggestions for my code i'd love to here them! Like I said, I'm new to it and thats the only way i know to do this.
------------> If anyone wants, I'll upload the entire project folder. Just ask. Thank you guys for all the help. i'm a n00b with xcode so i haven't got it all down yet.
Project Zipped
Post some code where you use finallabel and try to debug your app so you can tell me the line just before the app crashes.
Option 2:
Try to set a BreakPoint in malloc_error_break so we can have more info about the error.
In XCode go to Run -> Show -> BreakPoints (or just cmd + option + B). Then double click to add a new symbol (symbolic breakpoint) and type in malloc_error_break then press enter.
Now run your app and paste your console text.
UPDATE If you need help http://developer.apple.com/library/mac/#recipes/xcode_help-breakpoint_navigator/articles/adding_a_symbolic_breakpoint.html
Check your connections inside your InterfaceBuilder, you may have it wrong with fianllabel.
Also check your Custom Class -> Class in your iphone XIB in your InterfaseBuilder
UPDATE
Go to Product -> Clean. Then Run.
The line UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); just means that an exception was thrown during the running of your program. This could range from a memory problem, to a simple runtime error. Look in the target debugger console; it will tell you where the error occurred.
Open "iOS Simulator" Menu in the upper left->Reset Content and Settings. Then quit the iOS simulator and Xcode, and then restart your computer. This will get rid of the other instance of the process.
This May work it's work for me...........
The problem is with your XIB file. This error generally occurs when your finalLabel is incorrectly hooked up or doesn't exist anymore. Check your connections in the Interface Builder once.
I also had this error. After spending so much time, I found how to fix it. First of all go the console and see where is the error (mine was related to storyboards and its code) The way I fixed my error was by going in story board. Below the iPhone screen, there will be small yellow button. Right click on it and you will see that is causing error. Delete(x) it if there is yellow error sign.
If this does not fix your error then try to make new project and then replace its blank files with old files of your old project. I had same error in very beginning and by doing this program run without any error.
Other people suggests by restarting your laptop and running it again, reseting the iOS simulator, or changing iOS debugger (however this does not work in latest x code since there is only one debugger)
Hope this helps