Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6041327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:38:44+00:00 2026-05-23T06:38:44+00:00

Setup: I have a custom class I’ve created that handles data retrieved from a

  • 0

Setup: I have a custom class I’ve created that handles data retrieved from a web source using ASIHttpRequest. This data is json encoded. In the completion block of the async request , the custom object is allocated to memory and the json values are set to their corresponding properties. This object is property of the view. Within the completion block, a method to setup the view is called and the object is passed into a headerView which is subclassed from UIView and is then set to tableView.tableHeaderView. At this point everything works perfectly. UILabels in the headerView are set using the custom objects properties without a hitch.

Problem: Within the view, I have a UIBarButton that calls a method. When this method is called and I attempt access any property from the custom object, the program crashes (iPhone simulator freezes) and xcode points to the line in which the property is attempting to be accessed and says “Thread 1”. There aren’t any errors in the debugger. When I NSLog the custom object, there is a memory address returned which matches the address when I don’t have any problems accessing it.

Any ideas? Are their any debugging methods to help work this out? I don’t understand why one method of the view doesn’t have any problems accessing these properties and another would. Thanks.

Edit: I disabled zombies and I now receive a EXC_BAD_ACCESS error instead of no error at all.

Edit: Code

@class Obj, ObjHeader;
@interface ObjTableViewController : UITableViewController <UIActionSheetDelegate> {

@public
    NSString* objID;
@private
    Obj* obj;
    ObjHeader* headerView;
}
@property (nonatomic, retain) NSString* objID;
@property (nonatomic, retain) Obj* obj;

@property (nonatomic, retain) ObjHeader* headerView;

- (void)loadObj; // Loads Obj via async request
- (void)setupView; // This method runs after a async request is successful 

- (void)viewDidLoad
{   
    [self loadObj];
    [super viewDidLoad];
}

- (void)loadObj {
    // Start request
    ASIFormDataRequest* request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:OBJ_URL]];
    [request setPostValue:self.objID forKey:@"ObjID"];

    // Successful request
    [request setCompletionBlock:^{
        self.obj = [[Obj alloc] initWithString:[request responseString]];
        [self setupView];
    }];

    [request setFailedBlock:^{
        NSError *error = [request error];
        NSLog(@"Error on obj request with error %@",[error localizedDescription]);
    }];

    [request startAsynchronous];
}

    - (void)setupView {
        // Header setup
        self.headerView = [[ObjHeader alloc] initWithObj:self.obj];
        self.tableView.tableHeaderView = self.headerView;



        // Title 
        self.title = self.obj.name; // SUCCESSFUL ACCESS HERE
        UIBarButtonItem* optsButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction 
                                                                                     target:self 
                                                                                     action:@selector(showOpts:)] 
                                       autorelease];

        self.navigationItem.rightBarButtonItem = optsButton;

    }
- (void)showOpts:(id)sender {
    NSLog(@"%@",self.obj.name); // EXC_BAD_ACCES 
}

Obj Class

@interface Obj : NSObject {

@public
    NSString* name;
}

@property (nonatomic, readonly, retain) NSString* name;
- (id)initWithString:(NSString*)responseString;

- (id)initWithString:(NSString*)responseString {
    self = [super init];
    if(self) {
        NSArray* json = [[NSString stringWithString:responseString] JSONValue];
        name    = [json valueForKeyPath:@"Obj.Name"];
    } // END IF
    return self;
}

ObjHeader class – I’m pretty sure this is irrelevant because the problem still occurs when I don’t use it! 😛

@class Obj;
@interface ObjHeader : UIView {

@public
    UILabel* nameLabel;
}
@property (nonatomic, readonly, retain) UILabel* nameLabel;

- (id)initWithObj:(Obj*)obj;


- (id)initWithObj:(Obj*)obj
{
    CGRect frame = CGRectMake(0, 0, 320.0f, 480.0f / 4.0);
    self = [super initWithFrame:frame];
    if (self) {

        const CGFloat labelWidth = 320.0f - 15.0f;

        // Setup Name label
        const CGFloat nameFontSize = 17.0f;
        CGRect nameFrame = CGRectMake( 70.0f, 10.0f, 
                                      labelWidth, nameFontSize);
        nameLabel = [[UILabel alloc] initWithFrame:nameFrame];
        nameLabel.text = obj.name;
        nameLabel.font = [UIFont fontWithName:SYSFONT size:nameFontSize];
        [self addSubview:nameLabel];
    }
    return self;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:38:45+00:00Added an answer on May 23, 2026 at 6:38 am

    I think there’s a problem here:

     name    = [json valueForKeyPath:@"Obj.Name"];
    

    That’s an autoreleased object, so you want either self.name at the beginning or a retain on the end.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a custom dialog for Visual Studio Setup Project using the steps
I'm writing a plug-in for an application where I have a custom class that
I have a setup project with a custom installer class which launch the application
At the moment I have setup a custom ok cancel dialog with a drop
Setup I have a website that draws RSS feeds and displays them on the
Setup I have a VBScript for driving the stress testing of a web service.
I have setup web dav on windows server 2008. It seems to work fine
Here's the setup I have in a vs2008 solution: Data layer in a project
Setup: I have a combo-box, it's itemsource bound to an ObservableCollection<T> of a custom
Embedded custom-tag in dynamic content (nested tag) not rendering. I have a page that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.