Xamarin. Mac 應用程式基本概念Xamarin.Mac application fundamentals

常見模式和慣用語Common patterns and idioms

在透過公開的所有 Apple C#api 中,特定的慣用語和模式會重複出現。Throughout the Apple APIs exposed via C#, certain idioms and patterns come up over and over again. 如果您有使用 Xamarin 進行程式設計的經驗,這些功能看起來可能很熟悉。If you have experience with programming with Xamarin.iOS, these may look familiar. 檔通常會參考這些模式並重複慣用語,因此充分瞭解它們將有助於您瞭解所找到的檔。Documentation will often refer to these patterns and idioms repeatedly, so having a solid understanding of them will help you make sense of the documentation you find.

瞭解 Mac ApiUnderstanding Mac APIs

在大部分的C#情況下,使用 Xamarin 進行開發時,您可以考慮、閱讀和撰寫,而不需要擔心基礎的目標-C api。For much of your time developing with Xamarin.Mac, you can think, read, and write in C# without much concern with the underlying Objective-C APIs. 不過,有時候您必須閱讀 Apple 的 API 檔,將答案從 Stack Overflow 轉譯為問題的解決方案,或與現有的範例進行比較。However, sometimes you’ll need to read the API documentation from Apple, translate an answer from Stack Overflow to a solution for your problem, or compare to an existing sample.

主控台應用程式Console apps

您也可以建立「無周邊」主控台應用程式,以使用 Xamarin 來存取原生 macOS Api。You can also build "headless" console apps that access native macOS APIs using Xamarin.Mac.

使用 xib 檔案Working with .xib files

本文涵蓋如何使用在 Xcode 的 Interface Builder 中建立的 xib 檔案,來建立和維護 Xamarin. Mac 應用程式的使用者介面。This article covers working with .xib files created in Xcode's Interface Builder to create and maintain user interfaces for a Xamarin.Mac application.

. 分鏡腳本/. xib less 使用者介面設計.storyboard/.xib less user interface design

本文說明如何直接從C#程式碼建立 Xamarin. Mac 應用程式的使用者介面,而不需使用 Xcode 的 Interface Builder 搭配. 腳本或 xib 檔案。This article covers creating a Xamarin.Mac application's user interface directly from C# code without using Xcode's Interface Builder with .storyboard or .xib files.

使用影像Working with images

本文說明如何在 Xamarin. Mac 應用程式中使用影像和圖示。This article covers working with images and icons in a Xamarin.Mac application. 其中包括建立和維護建立應用程式圖示所需的影像,以及在程式C#代碼和 Xcode 的 Interface Builder 中使用影像。It covers creating and maintaining the images needed to create your application's icon and using images in both C# code and Xcode's Interface Builder.

資料系結和索引鍵-值編碼Data binding and key-value coding

本文涵蓋使用索引鍵/值編碼和索引鍵-值觀察,以允許資料系結至 Xcode 的 Interface Builder 中的 UI 元素。This article covers using key-value coding and key-value observing to allow for data binding to UI elements in Xcode's Interface Builder. 使用這項技術,您可以大幅減少需要C#為 Xamarin. Mac 應用程式撰寫的程式碼數量。Using this technique, you greatly reduce the amount of C# code that needs to be written for your Xamarin.Mac application.

使用資料庫Working with databases

本文說明如何使用索引鍵/值編碼和索引鍵-值觀察,以允許資料系結至 Xcode 的 Interface Builder 中的 UI 元素直接存取 SQLite 資料庫。This article covers using key-value coding and key-value observing to allow for data binding with direct access to SQLite databases to UI elements in Xcode's Interface Builder. 它也涵蓋如何使用 SQLite.NET ORM 來提供 SQLite 資料的存取權。It also covers using the SQLite.NET ORM to provide access to SQLite data.

使用複製和貼上Working with copy and paste

本文說明如何使用貼夾,以在 Xamarin. Mac 應用程式中提供複製和貼上。This article covers working with the pasteboard to provide copy and paste in a Xamarin.Mac application. 它會示範如何使用可在多個應用程式之間共用的標準資料類型,以及如何支援「提供應用程式」中的自訂資料。It shows how to work with standard data types that can be shared between multiple apps and how to support custom data within a give app.

沙箱化 Xamarin. Mac 應用程式Sandboxing a Xamarin.Mac app

本文說明如何在 App Store 上進行用於發行的 Xamarin. Mac 應用程式沙箱。This article covers sandboxing a Xamarin.Mac application for release on the App Store. 其中涵蓋所有進入沙箱的元素:容器目錄、權利、使用者決定的許可權、許可權區隔,以及核心強制。It covers all of the elements that go into sandboxing: container directories, entitlements, user-determined permissions, privilege separation, and kernel enforcement.

使用 Avaudioplayer 播放音效播放音效Playing sound with AVAudioPlayer

本文說明如何使用協助程式類別,以使用 Avaudioplayer 播放音效來控制音效的播放。This article shows how to use a helper class to control the playback of sound using an AVAudioPlayer.

報告錯誤Reporting bugs

有時候,在處理專案時,我們全都會停滯,因為無法取得 API 以我們想要的方式運作,或嘗試解決 bug。Sometimes we all get stuck while working on a project, either on the inability to get an API to work the way we want or in trying to work around a bug. 我們在 Xamarin 的目標是要讓您成功撰寫行動和桌面應用程式,並提供一些資源來協助您。Our goal at Xamarin is for you to be successful in writing your mobile and desktop applications, and we’ve provided some resources to help.