大家好我正在编写一个使用桥接器从c#调用的模块 这就是我初始化模块的方式。
AutocompliteCallBacks *del = [[AutocompliteCallBacks alloc] initWithSuccessAction:onSuccess AndWithFailureAction:onFailure];
我正在模块的初始化中直接传递我的块函数,我想知道是否可以从同一文件中的另一个void方法触发onSuccess块函数。
这是我的.mm文件
#pragma mark - GMSAutocompleteViewControllerDelegate
#include <Uno/Uno.h>
#include <@{ObjC.Object:Include}>
#include "placeautocompleteIOS.h"
@interface AutocompliteCallBacks ()
@end
@implementation AutocompliteCallBacks
// To receive the results from the place picker 'self' will need to conform to
// GMSPlacePickerViewControllerDelegate and implement this code.
- (void)viewController:(GMSAutocompleteViewController *)viewController didAutocompleteWithPlace:(GMSPlace *)place {
// Do something with the selected place.
[[[[UIApplication sharedApplication] keyWindow] rootViewController] dismissViewControllerAnimated:YES completion:nil];
NSLog(@"Place name %@", place.name);
NSLog(@"Place address %@", place.formattedAddress);
NSObject *object;
NSString *myString = place.formattedAddress;
[AutocompliteCallBacks callback:@"hahahah"];
}
- (void)viewController:(nonnull GMSAutocompleteViewController *)viewController didFailAutocompleteWithError:(nonnull NSError *)error {
[[[[UIApplication sharedApplication] keyWindow] rootViewController] dismissViewControllerAnimated:YES completion:nil];
}
- (void)wasCancelled:(nonnull GMSAutocompleteViewController *)viewController {
[[[[UIApplication sharedApplication] keyWindow] rootViewController] dismissViewControllerAnimated:YES completion:nil];
}
- (void)placePickerDidCancel:(GMSPlacePickerViewController *)viewController {
[[[[UIApplication sharedApplication] keyWindow] rootViewController] dismissViewControllerAnimated:YES completion:nil];
NSLog(@"No place selected");
}
-(void)callback: (NSString *)onSuccess
{
NSLog(onSuccess)
}
- (id)initWithSuccessAction:(void (^)(NSString *))onSuccess AndWithFailureAction:(void (^)(NSString *))onFailure
{
self = [super init];
if(self){
// onSuccess(@"this is the success")
}
return self;
}
@end