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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:06:13+00:00 2026-05-19T14:06:13+00:00

I am following along with a series of web tutorials relating to Objective-C and

  • 0

I am following along with a series of web tutorials relating to Objective-C and am now getting a “Accessing unknown origin getter method” error when i try to build my program (origin being a member of a Rectangle class that I created).

Here is my class titled PointXY:

#import <Foundation/Foundation.h>      
@interface PointXY : NSObject 
{
    int x;
    int y;
}

//Setters and Getters
@property int x;
@property int y;

//Methods
- (void) setXY : (int) xCO : (int) yCO;

@end

I then define a rectangle class, that has a member that is of type PointXY:

#import <Foundation/Foundation.h>
@class PointXY;
@interface rectangle : NSObject 
{
    float width;
    float height;
    PointXY * origin;

}

//Setters and Getters
@property float width, height;

//Instance Methods
- (float) getArea;
- (float) getPerimeter;

//We already have setters and getters defined for width
//and height. The below method is for illustration purposes
- (void) setHW: (float) h : (float) w;

//Methods to set and get origin values
- (PointXY *) getOrigin; //Returns a PointXY object
- (void) setOrigin : (PointXY *) point;

@end

I get the error in main, if i try to access the x or y property of my origin member via my NSLog statement:

#import <Foundation/Foundation.h>
#import "rectangle.h"
#import "PointXY.h"

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    //Create an object
    rectangle * myRectangle = [[rectangle alloc]init];
    PointXY * rOrigin = [[PointXY alloc]init];

    [rOrigin setXY:100 :100];
    myRectangle.origin = rOrigin;


    NSLog(@"The origin for the rectangle is %i, %i", myRectangle.origin.x, myRectangle.origin.y);


    [pool drain];
    return 0;
}

I understand that one cannot access the members without either explicitly defining a synthesized accessor or by creating a method to do just that and was surprised to see the author of the tutorial do the above with no issue.

Is the above even possible? Can I access myRectangle.origin.x without origin being synthesized in myRectangle or do I have something set up incorrectly.

Thanks for your time.

  • 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-19T14:06:14+00:00Added an answer on May 19, 2026 at 2:06 pm

    Origin is an instance variable you need to create an @property for it and synthesize it as you already know.

    //Setters and Getters
    @property float width, height;
    @property PointXY *origin;
    

    But without the property you could access the origin by doing this rectangle->origin but that defeats the purpose of encapsulation.

    Edit- origin will need to be defined as @public or @package

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

Sidebar

Related Questions

I'm getting started with Play 2.0 by following along with the tutorial. I'm hitting
I am following along with the Summer of NHibernate Screencast Series and am running
I am following along in Agile Web Development with Rails (rails 3.2+) and I
I am following along with the tutorials in 'Easy PHP Websites with Zend Framework'
I am following along in the .6 release of the WCF Web API chm
I am following along with the first video in the iTunes U course, and
I'm following along in my C# textbook and it says that C# assumes that
I am following along with the Rails 3 in Action book, and it is
I was following along with Ryan's RailsCast Episode 339. I had installed rbenv and
In an internship I'm following along in a really nice tutorial on making advanced

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.