简体   繁体   中英

Adding a viewController as an argument in Objective-C

I'm a swift developer, but I need to edit a codebase in Objective-C...I need to add a UIViewController as an argument in the below method, so that I can pass in self when I call it. Can anyone help me construct the method in Objective-C?

(I only need the argument in authenticate, not in silentlyAuthenticate). My end goal is that I'm trying to implement SafariViewController instead of Pinterest SDK's current openURL log in.

Classes I'm editing:

https://github.com/pinterest/ios-pdk/blob/master/Pod/Classes/PDKClient.h https://github.com/pinterest/ios-pdk/blob/master/Pod/Classes/PDKClient.m

My edits to code so far:

https://gist.github.com/gesabo/a29c015692c8d657cfe9c7fb1fc54707 https://gist.github.com/gesabo/bcf4d4f7b729e14a3d2dc9249bc8b54e

- (void)silentlyAuthenticateWithSuccess:(PDKClientSuccess)successBlock
                                 andFailure:(PDKClientFailure)failureBlock;
{
    [self authenticateWithPermissions:nil silent:YES withSuccess:successBlock andFailure:failureBlock];
}

- (void)authenticateWithPermissions:(NSArray *)permissions withSuccess:(PDKClientSuccess)successBlock andFailure:(PDKClientFailure)failureBlock
{
    [self authenticateWithPermissions:permissions silent:NO withSuccess:successBlock andFailure:failureBlock];
}

- (void)authenticateWithPermissions:(NSArray *)permissions
                             silent:(BOOL)silent
                        withSuccess:(PDKClientSuccess)successBlock
                         andFailure:(PDKClientFailure)failureBlock
{
    __weak PDKClient *weakSelf = self;

I am not sure if this is what you're asking - the change in .m file:

- (void)authenticateWithPermissions:(NSArray *)permissions
                     viewController:(UIViewController *)viewController
                        withSuccess:(PDKClientSuccess)successBlock  
                         andFailure:(PDKClientFailure)failureBlock
{
    // use viewController
}

Or the same change in the second method:

- (void)authenticateWithPermissions:(NSArray *)permissions
                     viewController:(UIViewController *)viewController
                             silent:(BOOL)silent
                        withSuccess:(PDKClientSuccess)successBlock
                         andFailure:(PDKClientFailure)failureBlock
{
    // use viewController
}

And in .h file the corresponding method declarations are also to be updated:

- (void)authenticateWithPermissions:(NSArray *)permissions
                     viewController:(UIViewController *)viewController
                        withSuccess:(PDKClientSuccess)successBlock  
                         andFailure:(PDKClientFailure)failureBlock;

and

- (void)authenticateWithPermissions:(NSArray *)permissions
                     viewController:(UIViewController *)viewController
                             silent:(BOOL)silent
                        withSuccess:(PDKClientSuccess)successBlock
                         andFailure:(PDKClientFailure)failureBlock;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM