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 5967817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:59:56+00:00 2026-05-22T19:59:56+00:00

The Imagepair object is a member variable of some other class.. I want its

  • 0

The Imagepair object is a member variable of some other class.. I want its members to be changed, every time I call the getImageURLs-function (requests a web page and parses its elements). The first time it works fine, but if I call the function a 2nd time on the same object, the application crashes and leaves me with a EXC_BAC_ACCESS Exception. My guess is, that I am doing something wrong with the memory management, but I cannot figure out what, as I’ve got a background in Java and am not really used to doing the memory management manually.

@implementation Imagepair

@synthesize imageLeft;
@synthesize imageRight;
@synthesize imageURLLeft;
@synthesize imageURLRight;
@synthesize idLeft;
@synthesize idRight;

//get random imagepair link
- (void) getImageURLs{
    NSLog(@"Get random imagepair from server");

NSError *error = nil;

NSURL *url = [NSURL URLWithString:cSERVER_GET_RANDOM_IMAGE];
ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:url];
[request startSynchronous];

//init HTML-parser
HTMLParser *parser = [[HTMLParser alloc] initWithString: [request responseString] error:&error];

//check for error
if (error) {
    NSLog(@"Error: %@", error);
}

//get body-node
HTMLNode *bodyNode = [parser body];

//get all link-nodes
HTMLNode *success = [bodyNode findChildTag:@"success"];
HTMLNode *imgurl1 = [success findChildTag:@"imgurl1"];
HTMLNode *imgurl2 = [success findChildTag:@"imgurl2"];
HTMLNode *imgid1 = [success findChildTag:@"imgid1"];
HTMLNode *imgid2 = [success findChildTag:@"imgid2"];
HTMLNode *imgvotes1 = [success findChildTag:@"imgvotes1"];
HTMLNode *imgvotes2 = [success findChildTag:@"imgvotes2"];

//read content and set members
[self setImageURLLeft:[imgurl1 contents]];
[self setImageURLRight:[imgurl2 contents]];
votesLeft = [[imgvotes1 contents] intValue];
votesRight = [[imgvotes2 contents] intValue];
[self setIdLeft:[imgid1 contents]];
[self setIdRight:[imgid2 contents]];
[self setImageLeft:[self requestImage:imageURLLeft]];
[self setImageRight:[self requestImage:imageURLRight]];

[request release];
[parser release];
}

//returns an UIImage for an URL
-(UIImage *)requestImage:(id)url{    
    NSURL *imgURL = [NSURL URLWithString:url];
    NSData *data = [NSData dataWithContentsOfURL:imgURL];
    UIImage *image = [[UIImage alloc] initWithData:data];
    return image;
    }
}
  • 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-22T19:59:56+00:00Added an answer on May 22, 2026 at 7:59 pm

    In requestImage: you initialize an UIImage but never release it. Either change return image to return [image autorelease] or rename the method to newRequestImage: so that it is clear that it returns a retained image.

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

Sidebar

Related Questions

HI, I want to display 20 random images at a time over Activity screen
There are a number of issues i'm having, all being related. Some I have
Edit for vhinn I want it to look like this: I am trying to
My question is this: If I know that a property of the object has
I've got a global Graphics object created from a Panel. At regular intervals an
I have following code in page load Protected Sub Page_Load(ByVal sender As Object, ByVal
I want to be able to show if an Image has been associated with
I am trying to get the value of variable a that is inside the
I have the following html: <div class=count-unit> <div class=count-digit digit0></div> <div class=count-digit digit6></div> </div>
I cannot think of a proper way to wait for an object to appear.

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.