2015-12-03 61 views
0

我正在使用pinterest SDK将图像发布到pinterest。但我无法弄清楚我需要传递的参数“withSuccess”和“andFailure”在我的应用程序中调用以下方法的数据?iOS Pinterest API

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

回答

0

这些都是回调函数 - 您编写的函数,当帖子成功或失败时会被调用。 例如,从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. 
        }]; 

的回调是一个类型的对象称为目标C. Apple's documentation“块”是一个合理的地方开始了解块,但有很多其他教程。

+1

非常感谢! – Franky