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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:24:05+00:00 2026-05-30T05:24:05+00:00

For object instances we can have their class declare some protocol conformance as in:

  • 0

For object instances we can have their class declare some protocol conformance as in:

@protocol P <NSObject>
- (void) someMethod ;
@end

@interface C : NSObject <P>
@end

@implementation C
- (void) someMethod {

}
@end

But what about classes?

I find myself in this situation:

...
Class c = [self modelClass:kind] ;
if (c) {
    model = [c performSelector: @selector(decode:) 
                    withObject: [SExpIO read: [fm contentsAtPath:target]]] ;
}

and I wish there were a way for me to declare that there is such a thing as protocols for class methods.

In the above example, all classes that c can be a class-instance (Hmmm??) of, declare

+ (id) decode: (SExp *) root ;

Is there a way that I could transform the above into:

if (c) {
    model = [c decode: [SExpIO read: [fm contentsAtPath:target]]]
}

by using a suitable “class protocol” declaration?

  • 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-30T05:24:06+00:00Added an answer on May 30, 2026 at 5:24 am

    There are such things as Protocols for class methods, and they’re called…. Protocols. For example, it looks like you want a protocol that looks like this:

    @protocol MyDecoder
    + (id)decode:(SExp *)root;
    @end
    

    You can then use it like this:

    Class c = [self modelClass:kind];
    if ([c conformsToProtocol:@protocol(MyDecoder)]) {
         model = [c decode: [SExpIO read: [fm contentsAtPath:target]]];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say, I have some classes: class NPC { Attributes attributes; Skills skills; void doStuff()
I have some javaScript Classes ( ctor+prototype methods) that I want their instances to
How I can store an instance object foreach user session? I have a class
When you have an object instance in C#, you can use the this keyword
How can I read/write serializable object instances to a RandomAccessFile in Java? I want
How can I create an instance of an object using a class reference, and
Is it possible for two instances of Object to have the same hashCode() ?
I have object A which contains multiple instances of object B, which in turn
I have controls which are not updating their bound object's respective properties until focus
For example, suppose I have the code: class Foo(object): def bar(self, x): '''blah blah

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.