开发者

Initialisation list in Objective C

I am porting cpp codes to obje开发者_运维百科ctive 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.


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜