开发者

Initialisation list in Objective C

开发者 https://www.devze.com 2023-03-03 16:33 出处:网络
I am porting cpp codes to obje开发者_运维百科ctive C. Is there any way to do the initialisation list declaration 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

精彩评论

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