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

  • Home
  • SEARCH
  • 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 8965217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:45:56+00:00 2026-06-15T16:45:56+00:00

I seem to have a pointer problem and I can’t seem o fix it.

  • 0

I seem to have a pointer problem and I can’t seem o fix it. Could someone help me, please?

-(void) connectionDidFinishLoading:(NSURLConnection *)connection{
    NSLog(@"Finished Downloading Image: %@" ,[connection.originalRequest.URL absoluteString]);
    UIImage *CompiledImage=[UIImage imageWithData:ImageData];
    SEL selector=@selector(ImageDownloadingCompleted:Image:);
    if([[self Delegate] respondsToSelector:selector]){
        [[self Delegate] ImageDownloadingCompleted:self Image:CompiledImage];
    }
    else{
        if(Target){
            *Target=CompiledImage;
        }
    }
    // NSLog(@"Image Size:%i", [ImageData length]);
}

Target is a private variable of type UIImage (declared: UIImage *Target;)
CompiledImage is a UIImage as well. What I want to do is set the contents of the address of target to be the Contents of CompiledTarget. This results in the following error:

Assigning to ‘UIImage’ from incompatible type ‘UIImage *__strong’

I tried :

memccpy(__bridge Target, &CompiledImage, sizeof(Target),sizeof(Target));

and I get this error:

Expected expression

  • 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-06-15T16:45:57+00:00Added an answer on June 15, 2026 at 4:45 pm

    You need to just set it as,

    Target = CompiledImage;
    

    No need of *. Since both are pointers basically you are assigning the memory address and not copying the contents if you use the above code.

    On a side note, please start variable names with lowercase letters. Target normally represents a class name. As per apple coding conventions, it should be target.

    As per your comment, you can do the following,

    In ViewController class, declare a UIImage as @property,

    @property (nonatomic, retain) UIImage *downloadedImage;
    

    While doing URL call,

    NSImageLoader *imageLoader = [[NSImageLoader alloc] init];
    [imageLoader setTarget:self];//setting current viewController as target instead of UIImage
    

    When image is downloaded,

    -(void) connectionDidFinishLoading:(NSURLConnection *)connection{
        NSLog(@"Finished Downloading Image: %@" ,[connection.originalRequest.URL absoluteString]);
        UIImage *CompiledImage=[UIImage imageWithData:ImageData];
        SEL selector=@selector(ImageDownloadingCompleted:Image:);
        if([[self Delegate] respondsToSelector:selector]){
            [[self Delegate] ImageDownloadingCompleted:self Image:CompiledImage];
        }
        else{
            if(Target){
                Target.downloadedImage = CompiledImage;//or [Target setDownloadedImage:CompiledImage];
            }
        }
        // NSLog(@"Image Size:%i", [ImageData length]);
    }
    

    In your ViewController class, now you can access image as, self.downloadedImage which will have same as in CompiledImage with same memory address pointing to the same location.

    An alternative way is to declare UIImage *Target as UIImage **Target in your NSImageLoader class. And while calling setTarget method, use [imageLoader setTarget:&Target];. Inside this method you need to set target as Target = Target;

    Update:
    Based on your comments it should be like this,

    for( NSDictionary *CurrentActivity in [Profile UserActivities]) {
            ...
            UIImage *WineImage = [UIImage imageNamed:@"loader.gif"];
            NSImageLoader *loader=[[NSImageLoader alloc] initWithURLString:[NSString stringWithFormat:@"%@%@",[TempSettings URL],[CurrentActivity objectForKey:@"ImageURL"]]];
            [loader setTarget:&WineImage];
            [loader startDownloading];
            [self addSubview:Activity];
            Counter++;
        }
    

    Then in NSImageLoader.h file @interface,

     __strong UIImage **Target; //This should be strong not autoreleasing
    

    In NSImageLoader.m file,

    - (void)setTarget:(UIImage *__strong *)iTarget{ //change here also
         Target = target; 
    } 
    
    
    -(void) connectionDidFinishLoading:(NSURLConnection *)connection{
        NSLog(@"Finished Downloading Image: %@" ,[connection.originalRequest.URL absoluteString]);
        UIImage *CompiledImage=[UIImage imageWithData:ImageData];
        SEL selector=@selector(ImageDownloadingCompleted:Image:);
        if([[self Delegate] respondsToSelector:selector]){
            [[self Delegate] ImageDownloadingCompleted:self Image:CompiledImage];
        }
        else{
            if(Target){
                *Target = CompiledImage;
            }
        }
        // NSLog(@"Image Size:%i", [ImageData length]);
    }
    

    Update2:

    Using the approach of passing UIImageView, you can do the following,

        for( NSDictionary *CurrentActivity in [Profile UserActivities]) {
            ...
            UIImage *WineImage = [UIImage imageNamed:@"loader.gif"];
            NSImageLoader *loader=[[NSImageLoader alloc] initWithURLString:[NSString stringWithFormat:@"%@%@",[TempSettings URL],[CurrentActivity objectForKey:@"ImageURL"]]];
            [loader setTarget:Activity];//pass imageview and let the delegate method set image
            [loader startDownloading];
            [self addSubview:Activity];
            Counter++;
        }
    
    -(void) connectionDidFinishLoading:(NSURLConnection *)connection{
        NSLog(@"Finished Downloading Image: %@" ,[connection.originalRequest.URL absoluteString]);
        UIImage *CompiledImage=[UIImage imageWithData:ImageData];
        SEL selector=@selector(ImageDownloadingCompleted:Image:);
        if([[self Delegate] respondsToSelector:selector]){
            [[self Delegate] ImageDownloadingCompleted:self Image:CompiledImage];
        }
        else{
            if(Target){
                Target.image = CompiledImage;
            }
        }
        // NSLog(@"Image Size:%i", [ImageData length]);
    }
    

    Here pass imageview and let the delegate method set image in that once you have downloaded the image.

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

Sidebar

Related Questions

Hopefully someone can give me a pointer. I have an application that makes several
I have a problem using a shared_ptr of a base class, I can't seem
I have a problem here, which I've not come across before and can't seem
I have been playing around with this problem since yesterday. I can't seem to
I have a what seems to be an easy problem yet I can't seem
I seem to have a problem passing some strings on from one form to
I seem to have a problem with getting MVC to fill in my custom
I seem to have the exact opposite problem than this question on stopping dock
I wonder whether someone may be able to help me please. From some demos
My problem is I can't seem to use @RenderSection from a nested template when

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.