Request for member 'pData' with BOOL value TRUE is not a structure or union-Objective C -
i not use pdata[4096] pass other function main.
data.m ------ @implementation data static int msgid; static char pdata[4096]="\0"; + (void)initialize { //some initialisations msgid =123; } -(void)swapendian:(uint8_t*)pdata withboolvalue:(bool)bisalreadylittleendian { nslog("%s %s",pdata,bisalreadylittleendian); } @end main.m ------- [dat swapendian:dat.pdata withboolvalue:true];
i getting pdata undeclared. pdata declared static inside data
implementation tried dat.pdata pass main.but when getting
request member 'pdata' bool value true not structure or union.
it difficult determine code supposed do, here how create objective-c object holds integer identifier , 4096-character array. please note sort of thing discouraged. unless have specific reason using int
, char[]
, identifier should nsinteger
, data should nsdata
or nsstring
object.
i have used of "standard" naming conventions. if writing cocoa code, helps drink lot of kool-aid.
message.h:
@interface message : nsobject { int identifier; char data[4096]; } @property (nonatomic, assign) int indentifier; @property (nonatomic, readonly) char * data; - (void)swapendian:(bool)flag; @end
message.m:
@implementation message @synthesize identifier; @synthesize data; - (id)init { if ((self = [super init]) == nil) { return nil; } identifier = 0; data[0] = '\0'; return self; } - (void)swapendian:(bool)flag { nslog(@"%s %d", data, flag); } @end
main.m:
#import "message.h" ... message * message = [[[message alloc] init] autorelease]; message.identifier = 123; [message swapendian:yes];
Comments
Post a Comment