RS232MsgGetEventDescriptions.h:
#define DECLARE_RS232_NEWMSG(ClassID)\
enum \
{ \
ID = ClassID \
}; \
@interface RS232MsgGetEventDescriptions : RS232Msg
{
}
@end
RS232MsgGetEventDescriptions.m
@implementation RS232MsgGetEventDescriptions
DECLARE_RS232_NEWMSG(RM_GET_EVENT_DESCRIPTIONS);
@end
EventLogs.m
-(void)event
{
service = [CServiceAppDlg alloc];
if ([service:(R开发者_如何学GoEMOTE_MESSAGE_ID)RS232MsgGetEventDescriptions.ID withEvent:pEvent])
{
NSLog(@"Get Event descriptions!!");
}
}
I'm getting an error like "Accessing Unknown 'ID' class method" I should not modify the definition here.How to pass the ID.I am going to call different descriptions ID in the same way so is this declaration of ID.
The reason why you are getting a Accessing Unknown 'ID' class method error message is because you have not declared a method called ID in your class RS232MsgGetEventDescriptions
.
When you say RS232MsgGetEventDescriptions.ID
in your code, you are calling the property ID
of object RS232MsgGetEventDescriptions
, which is equivalent to [RS232MsgGetEventDescriptions ID]
. However, RS232MsgGetEventDescriptions
is not an object, but a class and you don't have a class method called + (REMOTE_MESSAGE_ID)ID
in your class specification (you don't have it declared on the interface or implemented on the class implementation).
I would also like to point out that it is bad practice to use the dot notation for something other than a property. Since classes cannot have @properties (these are for objects) you should call this method using standard Objective-C messaging notation [RS232MsgGetEventDescriptions ID]
.
Xcode will still allow you to write object.methodName
to call methods with no parameters, and object.methodName = value
for methods that take 1 parameter. Because they are interpreted as follows:
object.methodName; // Becomes [object methodName]
object.methodName = value; // Becomes [object setMethodName:value]
精彩评论