开发者

Is it safe to declare blocks in init?

开发者 https://www.devze.com 2023-02-02 14:59 出处:网络
I need to call a function that takes a block.Does it cause a problem if I do so inside of an init method?

I need to call a function that takes a block. Does it cause a problem if I do so inside of an init method?


-开发者_运维问答 (id)initWithObjectThatWantsABlock:(Blar *)blar {
    if ((self = [super init])){

      [blar takeBlock:^{
          NSLog(@"Hi");
      }];

    }
}


Yes. It's still just a function, and as long as it doesn't depend on anything that you haven't initialised, it should be fine.

0

精彩评论

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