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

  • Home
  • SEARCH
  • 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 955449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:22:57+00:00 2026-05-16T00:22:57+00:00

I want to define one protocol with few properties and need to use those

  • 0

I want to define one protocol with few properties and need to use those properties in another NSObject subclass. Please give me link or example code. I need that to work with 10.5.

Thanks
PLEASE CHECK THE FOLLOWING SAMPLE CODE

@protocol MyProtocol
@property (nonatomic, readonly) id someObject;
@property (nonatomic, getter=isAlive) BOOL alive;
@end

#import "MyProtocol.h"
@interface MyCustomClass : NSObject <MyProtocol>{

}
@end

#import "MyCustomClass.h"
@implementation MyCustomClass
@synthesize someObject,alive;

/*
- (id)someObject {
    return nil;
}

- (BOOL)isAlive {
    return YES;
}

- (void)setAlive:(BOOL)aBOOL {
}
*/
@end

**Added:
Compling code with x86_64 architecture works fine. But error if i’ll change the architecture to i386, then i am getting following warnings:

MyCustomClass.m:13: error: synthesized property 'someObject' must either be named the same as a compatible ivar or must explicitly name an ivar

 error: synthesized property 'alive' must either be named the same as a compatible ivar or must explicitly name an ivar

I just want to know why it is working in x86_64 with @synthesize and not in i386.**

  • 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-16T00:22:57+00:00Added an answer on May 16, 2026 at 12:22 am

    @property just says to the compiler that the class is expected to define the methods to match that property.

    @protocol MyProtocol
    @property (nonatomic, readonly) id someObject;
    @property (nonatomic, getter=isAlive) BOOL alive;
    @end
    

    Anything implementing that protocol will now need to have

    - (id)someObject;
    - (BOOL)isAlive;
    - (void)setAlive:(BOOL)aBOOL;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have many cookie-cutter spring beans and don't want to explicitly define each one
I want to define some properties on a class using the [Indexable()] attribute in
I define one function in my .emacs, I want to activate ECB and goto
I want to define a macro that randomly chooses one of the given expressions
I want to define two servlets in my Spring web.xml - one for the
I often use it, and I know I can define one for myself in
I want to formally define a schema for a JSON-based protocol. I have two
I want to define one application level UncaughtExceptionHandler in my Java application that is
I want to define my own datatype that can hold a single one of
Problem solved now i want to define one edit text to left and other

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.