Angus
Angus

Reputation: 12621

Acessing structure declared from another file->Objective C

I am new to objective C.

remote.h

struct RMH_REQUEST_SESSION_MSG
{
    int  uDeviceID;
    int  uProtocolVersion;
    int  uReserved[5];
};

    @interface remote : NSObject {
   }
    @end




   data_derived.h

    #import "remote.h"

    @interface data_derived : data {

    @public
     RMH_REQUEST_SESSION_MSG st;

}

@end

Error:Expected specifier-qualifier-list before 'RMH_REQUEST_SESSION_MSG'

Here the structure declaration is made outside but i could not able to assign a variable

for this structure in another class that is declared in another file.I'm getting an

error.What has to be done to clear up this error.Thanks in advance.

Upvotes: 1

Views: 118

Answers (1)

Krishnabhadra
Krishnabhadra

Reputation: 34265

try

struct RMH_REQUEST_SESSION_MSG st;

instead of

RMH_REQUEST_SESSION_MSG st;

structure implementation in objective C is similiar to C structures..we need struct keyword when declaring structure variables..Else you can use typedef

typedef struct {
    int data1;
    char data2;
} RMH_REQUEST_SESSION_MSG;

and later..

RMH_REQUEST_SESSION_MSG st;

Upvotes: 1

Related Questions