Domanda

This might be a super simple bug, but my eyes are practically bleeding from trying to hunt it down. At first, I thought ARC might be playing a role, but now its completely disabled, and I'm still getting the bug.

I have a UMLLanguageProtocol protocol which defines a static method

+(NSArray *)methodFormatComponents;

I am trying to call that method within a function, but it is not being recognized by Xcode ("no known class method selector").

Here is the code where I am trying to use it:

#import "UMLLanguageProtocol.h"

@implementation UMLMethod

@dynamic documentation;
@dynamic name;
@dynamic umlClass;

+(void)validPortionOfMethod:(NSString *)method inLanguage:(Class<UMLLanguageProtocol>)language {
    [language methodFormatComponents];   <-- Error: No known class method selector 
}

@end

and the protocol itself, defined in UMLLanguageProtocol.h

#import <Foundation/Foundation.h>

#define VISIBILITY_SPECIFIER_COUNT 6

@class UMLMethod;
@class UMLAttribute;
@class UMLParameter;

typedef enum {
    PUBLIC, 
    PRIVATE, 
    PROTECTED, 
    PACKAGE,
    DERIVED,
    STATIC
} visibility;

@protocol UMLLanguageProtocol

/* 
 * Language Specifiers
 */
+(NSArray *)nativeDataTypes;

// Return a 6 item array with YES if the language supports that visibility
// specifier at the given index, and no if it doesn't.
+(NSArray*)visibilitySpecifiersForVariables;
+(NSArray*)visibilitySpecifiersForMethods;

/*
 * Parsing Methods
 */
// Returns a regex string that defines a validly formatted method
+(NSString *)methodFormat;
+(NSArray *)methodFormatComponents;

@optional
+(NSString*)documentationCommentFromText:(NSString*)comment;
+(NSString*)scaffoldTextFromMethod:(UMLMethod*)method;
+(NSString*)scaffoldTextFromParameter:(UMLParameter *)parameter;
+(NSString*)scaffoldTextFromAttribute:(UMLAttribute*)attribute;

+(NSArray *)additionalCommonDataTypes;
+(NSString *)defaultRootObject;

@end

Seriously, I'm losing hair as I write this... please help!


UPDATE: Actually, it seems the error is in two parts in the issue navigator. The first part is "Automatic Reference Counting Issue" and the second line is "No known class method for selector". That's odd, what could this possibly have to do with ARC?!

È stato utile?

Soluzione 2

No freaking way >:|

I just copied the contents of that protocol file, deleted it from my project, recreated it, pasted everything back in and it works. XCode, you will rue the day!!!!

My thanks to everyone who helped me out with this wild goose chase. I'm sorry the result was so unsatisfying :(

Altri suggerimenti

I think you need to change

[language methodFormatComponents];

to

[[language class] methodFormatComponents];

Still, though, @Ben S's point is good. It probably doesn't make sense for all your methods to be class level and should likely be changed to instance methods.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top