user565452
user565452

Reputation: 85

Is it safe to declare blocks in init?

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");
      }];

    }
}

Upvotes: 2

Views: 268

Answers (1)

Abizern
Abizern

Reputation: 150575

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.

Upvotes: 3

Related Questions