I'm trying to use a view controller that is only available in Objective-C. I have set up my Bridging-Header, but when I run my method it doesn't include a presentViewController
and gives the error No visible @interface for 'AlertSelector' declares the selector 'presentViewController...'
.m
#import "AlertSelector.h"
@implementation AlertSelector : NSObject
- (void) someMethod {
NSLog(@"SomeMethod Ran");
UIAlertController * view= [UIAlertController
alertControllerWithTitle:@"My Title"
message:@"Select you Choice"
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction* ok = [UIAlertAction
actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
//Do some thing here
[view dismissViewControllerAnimated:YES completion:nil];
}];
UIAlertAction* cancel = [UIAlertAction
actionWithTitle:@"Cancel"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[view dismissViewControllerAnimated:YES completion:nil];
}];
[view addAction:ok];
[view addAction:cancel];
[self presentViewController:view animated:YES completion:nil];
}
.h
@interface AlertSelector : NSObject
@property (strong, nonatomic) id someProperty;
- (void) someMethod;
@end
From Swift
var instanceOfCustomObject: AlertSelector = AlertSelector()
instanceOfCustomObject.someProperty = "Hello World"
print(instanceOfCustomObject.someProperty)
instanceOfCustomObject.someMethod()