অন্তহীন ছুটে চলা, অবিরাম জীবনের অর্থ খুজে ফেরা

Xamarin iOS: Learning by Examples: Part#1

Target Audience:

I expect you have basic iOS development experiences. A “Hello World” app written by you and installed in an iOS device would be suffice.

Also you have minimal working knowledge on C# language. You don’t have to be a guru. It also might possible if you know Java or C++. It should be hard for you to follow along C#.

Why Xamarin

Single language C# with convenience of .NET platform/libraries.

Native UI and Code sharing capabilities

Performance is as good as Native apps.

Xamarin cons

UI is not shared. As such, you need to have working knowledge of both Android and iOS platforms separately to develop apps in Xamarin. You will build Android UI with Android xml and iOS UI with storyboard. They have Xamarin.Forms, but thats a whole other story. I will try to write another series based on Xamarin.Forms

Implicitly the above point also means you need to have working knowledge of Android (Java/Xml), iOS (Swift/Storyboard) and C#/.NET. A great looking learning curve …

Xamarin is a commercial product. You need to pay $25 for each platform. So, building for iOS + Android + Windows, you need to pay $75/month. They do have a trial version and followed by a Starter edition after the trial period. However, it will get you only that much a free version can get.

Application size will be a bit larger than Native apps. like, 2.5 MB as of now.

Which part of code will be shared?

Following components can be shared across platforms

Models

Service layer

Data + Data access layer

Business layer

Network layer

Shared components will be written in C#. On top of this C# layer we will create UI layer using Xamarin.iOS and/or Xamarin.Android. App layer (connection between UI and App) will also be written in C#, but it won’t be shared. On average you can share 60% code, rest 40% will be UI and App layer.

PCL (Portable Class Library)

PCL is a C# library that can be used as a library project on multiple platforms. PCL follows common denominator approach. That means, you can incorporate common features of the platforms in a PCL library.

You may encounter an issue of not resolving method. Syntax highlighting will display the error like this,

To resolve this case, Right click on the item -> Resolve -> using System.Linq;

Alternatively add this line at the top of the file,

using System.Linq;

To make separation of concern, create another class named UserDataService.cs under Service Folder (Create a folder named Service). This class will contain methods of same signature as UserRepo.cs. The purpose of this class to delegate task to UserRepo class.