Hi guys, I have created a UI on Mac OS recently (Not phone Apps), and I am trying to link it to an additional Objective C code.
The source of this approach is really limited as all I found was about phone apps development. Hence I am trying to verify whether my concept is do-able or not. My Approach is as below :
My solution consist of Objective C and C#, which is linked internally when I created a new solution. These are done in the background by developers of these templates, where C# is the main sequence of the whole User Interface operations. Now I have created an Objective C file (externally), with all the functions to be called in its header file. I would love to link my UI (C# and Objective-C) to this Objective C file, the similar way developers used to link C# to Objective C.
This is the only link related to the subject that I am looking for, unfortunately it is mainly about phone Apps development.
https://docs.microsoft.com/en-us/xamarin/ios/platform/binding-objective-c/index
Below are small parts of my code /:
UI code:
MainViewController.designer.cs (Visual Studio for Mac)
using Foundation;
using System.CodeDom.Compiler;
namespace Main
{
[Register ("MainViewController")]
partial class MainViewController
{
[Outlet]
AppKit.NSButton btnConnect { get; set; }
[Action ("btnSubWindow:")]
partial void BtnPopOut (AppKit.NSButton sender);
}
void ReleaseDesignerOutlets ()
{
if (btnConnect != null) {
btnConnect.Dispose ();
btnConnect = null;
}
}
}
MainViewController.m (Xcode)
#import "TestLauncherViewController.h"
@implementation TestLauncherViewController
@synthesize btnConnect = _btnConnect;
- (IBAction)btnSubWindow:(NSButton *)sender {
}
@end
MainViewController.h (Xcode)
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
@interface TestLauncherViewController : NSViewController {
NSButton *_btnConnect;
@property (nonatomic, retain) IBOutlet NSButton *btnConnect;
- (IBAction)btnSubWindow:(NSButton *)sender;
@end
From here, we know that Objective-C has been linked to C#, and ready to be altered from C#.
Below are part of my externally created Objective C file:
Addition.h
@interface Addition : NSObject{
int progress;
Status state;
}
-(instancetype)initWithIP:(char*)ipaddress andUIdelegate:(id)del;
-(void)startToRun;
-(int)Multiplication;
@end
I am trying to use C# to access this Objective C header file to search for the entry point of any functions that I wish to call.
Please tell me if my concept is doable or not.
If do-doable :
Please provide me some guidance to achieve this approach.
Thank you in advance.