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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:51:28+00:00 2026-05-26T19:51:28+00:00

The variables bounds, width and height are at present local variables. I cannot access

  • 0

The variables bounds, width and height are at present local variables. I cannot access them from other classes or even access them from another method.

How can I make these variables available to the whole instance? I have tried placing them within the .h file and renaming them to CGFloats to no avail.

#import "TicTacToeBoard.h"

@implementation TicTacToeBoard

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)drawRect:(CGRect)rect
{
    CGRect bounds = [self bounds];
    float width = bounds.size.width;
    float height = bounds.size.height;

    CGContextRef ctx = UIGraphicsGetCurrentContext();
    CGContextSetRGBStrokeColor(ctx, 0.3, 0.3, 0.3, 1);
    CGContextSetLineWidth(ctx, 5);
    CGContextSetLineCap(ctx, kCGLineCapRound);

    CGContextMoveToPoint(ctx, width/3, height * 0.95);
    CGContextAddLineToPoint(ctx, width/3, height * 0.05);
    CGContextStrokePath(ctx);

}

@end
  • 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-26T19:51:28+00:00Added an answer on May 26, 2026 at 7:51 pm

    You can use properties to make variables accessible to other objects.

    In your interface add something like this:

    @property (nonatomic, retain) NSString *myString;
    

    and then add

    @synthesize mystring;
    

    to your implementation.

    Two methods will be created to get the property and to change it.

    [myObject myString]; // returns the property
    [myObject setMyString:@"new string"]; // changes the property
    
    // alternately, you can write it this way
    myObject.myString;
    myObject.mystring = @"new string";
    

    You can change the value of a property within a class using [self setMystring:@"new value"] or if you have the same variable already declared in the interface and then create a property from it you can keep using your variables within the class the way you are .

    There’s more info on properties in the developer docs: http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/objectiveC/Chapters/ocProperties.html#//apple_ref/doc/uid/TP30001163-CH17-SW1

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

Sidebar

Related Questions

I want to create variables inside a function from a dictionary. Let's say I
Is there any way to modify the bound value of one of the variables
Session variables are apparently not working for me. I don't know what I'm doing
//assign variables string measurementIn; //read in file in array string[] lines = File.ReadAllLines(../../convert.txt); //ask
Are PHP variables passed by value or by reference?
While answering Static class variables in Python I noticed that PythonWin PyWin32 build 209.2
If you declare variables of type byte or short and attempt to perform arithmetic
When you're passing variables through your site using GET requests, do you validate (regular
If I have two variables: Object obj; String methodName = getName; Without knowing the
Definition of variables in use: Guid fldProId = (Guid)ffdPro.GetProperty(FieldId); string fldProValue = (string)ffdPro.GetProperty(FieldValue); FormFieldDef

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.