what want cause save anytime saveinbackgroundwithblock called in app. im doing create "log" of changes , changed it. looked pfobject.h not sure how write in obj-c or else/how other going through , adding every single instance. way it? or should stick out , use harder way?
- (void)saveinbackgroundwithblock:(nullable pfbooleanresultblock)block;
you have multiple ways in order achieve kind of functionality:
- create util class receive pfobject , pfbooleanresultblock parameters util class execute call saveinbackgroundwithblock inside callback can implement additional save need. @ end util class should following:
@interface parseutils : nsobject + (void)saveparseobject:(pfobject *)object block:(pfbooleanresultblock)block; @end
@implementation parseutils + (void)saveparseobject:(pfobject *)object block:(pfbooleanresultblock)block { // if object nil or not changed return if (!object || !object.isdirty) return; [object saveinbackgroundwithblock:^(bool succeeded, nserror * _nullable error) { // if no error occured if (!error){ // here should call additional save... } // handle callback calling class if (block){ block(succeeded,error); } }]; } @end
another option same singleton (if created rest client singleton project)
another nice option create category on top of pfobject , there create method same method of util
there more options think it's enough.. if want quick possible use utilities. if want best architecture go category.
Comments
Post a Comment