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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:40:46+00:00 2026-05-16T20:40:46+00:00

If you synthesize a custom class, do getters and setters get created for it?

  • 0

If you synthesize a custom class, do getters and setters get created for it?

This is the custom class I created.

//  MyClass.h
#import <Foundation/Foundation.h>


@interface MyClass : NSObject <NSCoding> {
    NSString *string1;
    NSString *string2;

}
@property (nonatomic, retain) NSString *string1;
@property (nonatomic, retain) NSString *string2;

@end

Here I declare an object of that class as a property

//  DetailViewController.h


#import <UIKit/UIKit.h>
#import "MyClass.h"


@interface DetailViewController : UIViewController {

    MyClass *myObject;
}
@property(nonatomic, retain) MyClass *myObject;

@end

Here I synthesize the object.

#import "DetailViewController.h"
#import "MyClass.h"


@implementation DetailViewController
@synthesize myObject;

So does it have getters and setters?

When I try to run this code inside RootViewController.m

DetailViewController.myObject = [theArray objectAtIndex:indexPath.row];

I get an error saying “Accessing unkown ‘setMyObject:’ class method. Object cannot be set – either readonly property or no setter found.’

  • 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-16T20:40:46+00:00Added an answer on May 16, 2026 at 8:40 pm

    Only if you declare the desired instance variables as properties, then synthesize propname;, will getters and setters be created. Now, what kind of code goes into the getters and setters depends on what property attributes you define (nonatomic/atomic, assign, retain, copy)

    EDIT to OP’s revised question: Yes a getter/setter will be created for the myObject instance variable of the DetailViewController class

    DetailViewController.myObject = [theArray objectAtIndex:indexPath.row];

    You are attempting to set a class variable that isn’t defined. DetailViewController is of type Class, not DetailViewController. Perform the same operation on an instance of DetailViewController and you should be all set.

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

Sidebar

Related Questions

In my app , i created my custom class and i am observing one
I am having trouble loading from saved data an instance of a custom class
import I am trying to implement a custom cell to use in my tableview
I'm attempting to display my data, which is in a UITableView, in custom cells
I want to create a custom TableViewCell on which I want to have UITextField
Why does this leak? The arrayOfPerformances is a NSMutableArray , (nonatomic, retain) property that
I want to display custom cells, but my code is only displaying one custom
I am writing a framework and I have an object with a custom init
Bit of an Objective-C rookie, I've looked around for an answer but haven't been
I'm subclassing UINavigationController and UITableview and for some reason, my views are leaking memory,

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.