iOS 平特雷斯特 API

iOS Pinterest API

我正在使用 pinterest SDK post 图片到 pinterest。但是,在我的应用程序中调用以下方法时,我无法弄清楚我需要为参数 "withSuccess" 和 "andFailure" 传递哪些数据?

-(void)createPinWithImageURL:(NSURL *)imageURL link:(NSURL *)link onBoard:(NSString *)boardId description:(NSString *)pinDescription withSuccess:(PDKClientSuccess)successBlock andFailure:(PDKClientFailure)failureBlock;

这些是回调 - 您编写的函数会在 post 成功或失败时调用。 例如,在 Pinterest's documentation 中,您可以通过以下方式调用具有成功和失败回调的类似方法:

[[PDKClient sharedInstance] getPath:@"me/"
                    parameters:nil
                   withSuccess:^(PDKResponseObject *responseObject) {
                       // success actions - the code you write here will
                       // be called if the call succeeds.
                       // responseObject will contain information about
                       // the result of the call.
                   } andFailure:^(NSError *error) {
                       // failure actions - the code you write here will
                       // be called if the call fails. error will give
                       // you information about why the call failed.
                   }];

回调是一种在 Objective C 中称为 "block" 的对象。 Apple's documentation 是开始学习块的合理起点,但还有很多其他教程。