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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:08:24+00:00 2026-05-25T11:08:24+00:00

if(eventRecord.byName){ presented.text = eventRecord.byName; float descPos = 50.0; }else{ [presented removeFromSuperview]; float descPos =

  • 0
 if(eventRecord.byName){
        presented.text = eventRecord.byName;   
        float descPos = 50.0;
  }else{
        [presented removeFromSuperview];
        float descPos = 35.0;
  }


CGRect descFrame = CGRectMake(125, descPos, 185, descStringSize.height);

I’m not even sure what to do here since the whole time I’ve been working with objective-c has been with objects. But now, I need to set a variable with a float value depending on the condition. I’m not sure what the syntax should be.

On a side note, xcode4 has the last line as an error because descPos is undeclared. But won’t it be once the condition is run?

  • 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-25T11:08:24+00:00Added an answer on May 25, 2026 at 11:08 am

    You are only declairing descPos within the scope of the if statement. To access the value you are setting inside the if block, declare it beforehand:

    float descPos;
    if(eventRecord.byName){
        presented.text = eventRecord.byName;   
        descPos = 50.0;
    } else{
        [presented removeFromSuperview];
        descPos = 35.0;
    }
    
    CGRect descFrame = CGRectMake(125, descPos, 185, descStringSize.height)
    

    Otherwise, the way you are doing it, the value of descPos is discarded as soon as the block ends (with the } brace).

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

Sidebar

Related Questions

I have set an event successfully using myEntry.setTitle(new PlainTextConstruct(TEST)) myEntry.setContent(new PlainTextConstruct(See how much text
I`ve created simple hello world-like plugin which draws red box. Аfter embedding into xulrunner
This should be a simple one. Let's say I'm designing a very simple timeclock
Ok, I'm now very confused. After my last question had several people comment about
I've seen a few questions on this topic already but I'm looking for some
This is the example code, I'm using these functions for a program, but scanf
I have just started learning Scala and I'm now wondering how I could implement
If I throw an unhandled exception from ASP.NET, a warning is added to the
I am running an ASP.NET 3.5 web application on IIS 7 on Windows Server
I have been trying to set up a baisc calendar example to play around

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.