开发者

Program received signal: "EXC_BAD_ACCESS" while adding subview to main view

开发者 https://www.devze.com 2023-02-09 05:52 出处:网络
i am adding two labels and two image view to subview. when ever i tap on the button i add this subview to mainview.

i am adding two labels and two image view to subview.

when ever i tap on the button i add this subview to mainview.

I am getting images from the web server and save it in local simulator documents.

NSMutableString *about_name_str = [[NSMutableString alloc]init];
    [about_name_str appendString:[myDictionary objectForKey:@"firstname"]];
    [about_name_str appendString:@" "];
    [about_name_str appendString:[myDictionary objectForKey:@"lastname"]];
    [about_name_label setText:about_name_str]; 
    NSMutableString *about_addr_str = [[NSMutableString alloc]init];
    [about_addr_str appendString:[myDictionary objectForKey:@"state"]];
    [about_addr_str appendString:@","];
    [about_addr_str appendString:[myDictionary objectForKey:@"country"]];
    [about_addr_label setText:about_addr_str];
    about_image.image = [UIImage imageWithContentsOfFile:imagepath];
    about_logo.image = [UIImage imageWithContentsOfFile:logopath];
    if ([myDictionary objectForKey:@"companyurl"]) {
        [about_url_button setTitle:[myDictionary objectForKey:@"companyurl"] forState:UIControlStateNormal];
        about_url_button.userInteractionEnabled = YES;
    }
    else {
        about_url_button.userInteractionEnabled = NO;
    }




        [self.view addSubview:about_view];

this my code.

some times i got Program received signal: "EXC_BAD_ACCESS". and application quits.

i check by placing break poi开发者_开发知识库nts,and in debugger i did n't get where i am getting error.

can any one please help me,How can i resolve this.

Thank u in advance.


Try to use NSZombie.. It is a easy way to find where the EXCBADACCESS occurs... It will specify which Method where and Which object gets deallocated(Its pretty awesome concept i like in Instruments)...

See this Link http://www.markj.net/iphone-memory-debug-nszombie/


You should insert a breakpoint before this code is executed then step through it to find the exact line which is causing the bad access. You probably have a null or wild pointer somewhere.

0

精彩评论

暂无评论...
验证码 换一张
取 消