Xamarin.Mac • Full use of Mac APIs • JIT compiled to native code at run-time • side-by-side with the ObjC runtime • Mono runtime embedded into bundle • Allows the execution of dynamically generated code (in contrast to X.iOS) https://developer.xamarin.com/guides/mac/advanced_topics/mac-architecture/
Cocoa Binding • Keeping model and view values synchronized without a lot of glue-code • NSObject could raise an alert such as INotifyPropertyChanged in XAML platforms • Only supported with Mac https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CocoaBindings/Concepts/WhatAreBindings.html
Cocoa Binding Recipes 1.Remove glue-code from our first Mac App 2.Bind to property in ViewController 3.Bind to properties in other class 4.Bind to multiple values to select one of them
DataSource Pattern • Providing data by implementing a data source class • Permits fine control of populating rows and columns • Implement the NSTableViewDataSource and the NSTableViewDelegate protocols
DataSource Pattern Recipes 1.Implementing ITableViewDataSource and ITableViewDelegate 2.Recall previous value 3.Sorting previous values with direction (time permits)
Summary of live coding • Constructing Mac App using Visual Studio • Cocoa Binding basics • WillChangeValue/DidChangeValue • Protocol in C# • INSTableViewDataSource/Delegate
Showcase: Gochiusearch A Fast Scene Search Engine for Anime Series 'Is the order a rabbit?’ originally created with Windows.Forms ported to Cocoa with Xamarin.Mac published to MacAppStore • www.github.com/ksasao/Gochiusearch
APPROACH 1.Wash away platform dependent codes 2.Construct user interface using XIB for supporting macOS 10.9 3.Implement features using Full Desktop Mono 4.Migrate core features to Xamarin.Mac Modern 5.Submit to AppStore
Xamarin.Mac Modern • App runs on same tuned .NET framework used by X.iOS • Supporting a subset of the full Desktop framework • Linker behavior makes bundle size smaller • Could reference assemblies targeting netstandard>=1.0 or Xamarin.Mac20
APP SANDBOXING • Required for any app distributed from Mac App Store • Modify App Sandbox Resources by editing Entitlements.plist • Sandbox Violation does not throw NotAuthorizedException • Type of exception depends on operation • To determine whether violation occurred or not, use Console app
Unleash the power of Xamarin.Mac • No simulator or tethered device needed • Cherry pick the best bits of .NET Framework and Cocoa • Consider whether sharing more code or writing convenient and/or efficient platform dependent code