ios - Need assistance understanding part of blocks -
i reading ray wenderlich in-app purchases tutorial, , want understand block part of it.
_completionhandler = [completionhandler copy];whycopyused assign block variable?this block:
[[rageiaphelper sharedinstance] requestproductswithcompletionhandler:^(bool success, nsarray *products) { if (success) { _products = products; [self.tableview reloaddata]; } [self.refreshcontrol endrefreshing]; }];is passed parameter method, method present in class. how class reference class
tableview,refreshcontrol?
blocks exist on stack. in order keep block around after goes out of scope need
copymove heap. can treat other object , use later. in example copying block ivar can used in method.when pass block parameter encapsulates variables local scope , can access them after go out of scope. see documentation here.
Comments
Post a Comment