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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:12:43+00:00 2026-05-25T20:12:43+00:00

What I have is a advertisement Class that has an instance variable that will

  • 0

What I have is a advertisement Class that has an instance variable that will receive the banner url:

@interface Advertisement : UIViewController {

}


@property (nonatomic, retain) NSString *image;

Now, in my app delegate I am initializing the ad class and giving the instance variable “image” a value.

   //setup the ad
    Advertisement *theAdView = [[Advertisement alloc] init];
    theAdView.view.frame = CGRectMake(0.0, self.window.frame.size.height-120.0, 320.0, 76.0);
    theAdView.view.clipsToBounds = YES;
    theAdView.view.tag = AD_TAG;
    NSLog(@"Added the image");
    theAdView.image = theAd.banner;
    theAdView.nid = theAd.nid;
    [self.window addSubview:theAdView.view];
    [self.window bringSubviewToFront:theAdView.view];     

In the advertisement class’ viewDidLoad method I want the value of the “image.” However I get a null value. So it looks like the class is initializing before it gets a chance to get the instance variables.

I think I found a solution before, but I can’t remember exactly what. I believe it had something to do with setting another variable that does not use (nonatomic, retain)… I’m not sure.

  • 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-25T20:12:44+00:00Added an answer on May 25, 2026 at 8:12 pm

    a UIViewController will load it’s view (from nib or call the loadview method if you’ve overriden it) when you attempt to access it’s ‘view’ property. In your case, 1 easy result would be to move the lines

    theAdView.image = theAd.banner;
    theAdView.nid = theAd.nid;
    

    to before anything that accesses the view property, like

     theAdView.view.frame = CGRectMake(0.0, self.window.frame.size.height-120.0, 320.0, 76.0);
    

    or a better one would be to accept the image and nid as properties in a new initializer

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

Sidebar

Related Questions

I have an Advertisement UIViewController class that contains the following code. The frame is
Is it possible to have a div.class different based on a class that is
Quick question just to verify something. If I have an HTML5 mobile advertisement that
I have this ad class which contains an UIImageView. I've added an instance of
I have a SWF file used as a banner advertisement but there is a
I have a 1 table database that has a list of advertisements. I am
I am starting to develop an Android app and I have seen that in
I have this HTML code : <div class=headerPages> <div style=right: 0px> <ul dir=rtl> <li
I have an advertisement section on my website. For most users, this loads just
I am currently working on a website that is an advertisement portal for businesses.

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.