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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:37:24+00:00 2026-05-22T12:37:24+00:00

in this block of code my uiimageview always get nil.as a result the code

  • 0

in this block of code my uiimageview always get nil.as a result the code crashes.i can t figure out where is the uiimageview getting nil.in this code self refers to uitableviewcell.
the code crashes in the code where i am inserting the imageview to the array.is this a problem of memory retain?

MyAppDelegate *appDelegate =(myAppDelegate *)[[UIApplication sharedApplication]delegate];
        UIImageView *profileImageView;
        UILabel *tweetLabel;
        UILabel *timeLabel;
        UILabel *profileNameLabel;
        UIView *message;
        if(self==nil)
        {


        profileImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
        profileImageView.backgroundColor= [UIColor clearColor];
        profileImageView.tag = 1;

        tweetLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        tweetLabel.backgroundColor = [UIColor clearColor];
        tweetLabel.tag = 2;
        tweetLabel.numberOfLines = 3;
        tweetLabel.lineBreakMode = UILineBreakModeWordWrap;
        tweetLabel.font = [UIFont systemFontOfSize:10.0];
        tweetLabel.textColor=[UIColor blackColor];

        timeLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        timeLabel.backgroundColor = [UIColor clearColor];
        timeLabel.tag = 3;
        timeLabel.numberOfLines = 1;
        timeLabel.lineBreakMode = UILineBreakModeWordWrap;
        timeLabel.font = [UIFont systemFontOfSize:12.0];
        timeLabel.textColor=[UIColor blackColor];

        profileNameLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        profileNameLabel.backgroundColor = [UIColor clearColor];
        profileNameLabel.tag = 4;
        profileNameLabel.numberOfLines = 1;
        profileNameLabel.lineBreakMode = UILineBreakModeWordWrap;
        profileNameLabel.font = [UIFont boldSystemFontOfSize:14.0];
        profileNameLabel.textColor=[UIColor blackColor];

        message = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.frame.size.width, self.frame.size.height)];
        message.tag = 0;
        [message addSubview:profileImageView];
        [message addSubview:tweetLabel];
        [message addSubview:timeLabel];
        [message addSubview:profileNameLabel];

        [self addSubview:message];
        }
        else{
            tweetLabel = (UILabel *)[[self.contentView viewWithTag:0]viewWithTag:2];
            timeLabel = (UILabel *)[[self.contentView  viewWithTag:0]viewWithTag:3];
            profileNameLabel = (UILabel *)[[self.contentView  viewWithTag:0]viewWithTag:4];

        profileImageView = (UIImageView *)[self.contentView viewWithTag:1];
        NSLog(@" profileImageView %@",profileImageView);
        }
        NSString *tweet=[tweetObject tweet];
        NSString *profileName=[tweetObject author];
        NSString *time=[tweetObject time];



        CGSize textSize = [tweet sizeWithFont:[UIFont systemFontOfSize:14.0] constrainedToSize:CGSizeMake(240.0f, 480.0f) lineBreakMode:UILineBreakModeWordWrap];
        CGSize timeSize = [time sizeWithFont:[UIFont systemFontOfSize:14.0] constrainedToSize:CGSizeMake(240.0f, 480.0f) lineBreakMode:UILineBreakModeWordWrap];
        CGSize profileNameSize = [profileName sizeWithFont:[UIFont boldSystemFontOfSize:14.0] constrainedToSize:CGSizeMake(240.0f, 480.0f) lineBreakMode:UILineBreakModeWordWrap];

        profileImageView.frame = CGRectMake(5,self.frame.size.height/2, 44, 44);
        NSLog(@" profileImageView %@",profileImageView);
            tweetLabel.frame = CGRectMake(54, profileImageView.frame.size.width, 240,25);

        timeLabel.frame = CGRectMake(180, 5.0f, 100,  timeSize.height);

        profileNameLabel.frame = CGRectMake(54,5, 150, profileNameSize.height);
        tweetLabel.text=tweet;
        timeLabel.text=time;
        profileNameLabel.text=profileName;


        profileImageView.image = [[UIImage imageNamed:@"fbdefaultProfile.gif"]retain];
        NSLog(@" myArray WILL FILL WITH  THIS ELEMNTS %@ %@ %@ ",profileImageView,[tweetObject imageURL],@"fbdefaultProfile.gif");
        NSArray *myArray =  [NSArray arrayWithObjects:profileImageView,[tweetObject imageURL],@"fbdefaultProfile.gif",nil];
        NSLog(@" myArray %@",myArray);
        NSLog(@"%@ myArray ",myArray);
        [appDelegate performSelectorInBackground:@selector(updateImageViewInBackground:) withObject:myArray];

        }
        return;
  • 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-22T12:37:25+00:00Added an answer on May 22, 2026 at 12:37 pm
    if(self==nil)
            {
    

    what is this.. I think it should be

     if(self!=nil)
            {
    

    and if it is fine then why are you adding subview to a nill

     if(self==nil)
            {
    
            //your code .....
            //and then you are adding sub view to a nil which is useless
            [self addSubview:message];
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Considering this code, can I be absolutely sure that the finally block always executes,
consider this code block public void ManageInstalledComponentsUpdate() { IUpdateView view = new UpdaterForm(); BackgroundWorker
In other words, a block of code like this: (setq initial-major-mode (lambda () (text-mode)
I'm tearing my hair out with this one. If I start a block comment
This block of code essentially takes a JAXB Object and turns it into a
I'm using this block of code (mostly copied from a PHP.net comment here -
So, I have this block of code, and yes it looks ugly. Is there
I've run into a couple different exceptions with this block of code in one
i have this block of xslt if-else case and was wondering if there's a
I have this line in a javascript block in a page: res = foo('<%=

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.