spandana
spandana

Reputation: 755

Initialisation list in Objective C

I am porting cpp codes to objective C. Is there any way to do the initialisation list declaration in objective C.

RsMsgRequestSession::RsMsgRequestSession()
: RsMsg(ID,NewMsg,NULL,&st,sizeof(st))
{
}

How to declare the same equivalent in objective C.

Upvotes: 0

Views: 81

Answers (1)

justin
justin

Reputation: 104698

I am new to objective C.I am porting cpp codes to objective C.

...why? (as long as you know that it's not usually a worthwhile investment)

Is there any way to do the initialisation list declaration in objective C.

the equivalent of:

RsMsgRequestSession::RsMsgRequestSession() : RsMsg(ID,NewMsg,NULL,&st,sizeof(st)) {}

is:

@interface RsMsgRequestSession : RsMsg
@end

@implementation RsMsgRequestSession

- (id)init {
    // assuming one of RsMsg's designated initializers take the form:
    self = [super initWithID:ID message:NewMsg ambiguousArgumentName:NULL roleOfSt:&st sizeOfSt:sizeof(st)];
    if (nil != self) {
        /* init self here */
    }
    return self;
}

@end

Upvotes: 2

Related Questions