Xamarin Certification Xamarin.iOS Development 2 — Questions and Answers
Question 1: Which Xamarin.iOS method is called when the app moves to the background?
- DidEnterBackground (Correct answer)
- OnPause
- WillResignActive
- OnStop
Correct answer: DidEnterBackground
DidEnterBackground in AppDelegate is called when the application transitions to the background state.
Question 2: What is the role of UIViewController in Xamarin.iOS?
- Manages a single screen's view and lifecycle (Correct answer)
- Handles HTTP requests
- Provides data persistence
- Manages app-level navigation
Correct answer: Manages a single screen's view and lifecycle
UIViewController controls a single screen, managing the view hierarchy and responding to lifecycle events.
Question 3: In Xamarin.iOS, how do you navigate to a new view controller using a UINavigationController?
- PushViewController (Correct answer)
- StartActivity
- NavigateTo
- ShowViewController
Correct answer: PushViewController
PushViewController pushes a new UIViewController onto the navigation stack.
Question 4: Which API is used in Xamarin.iOS to request permission to send push notifications?
- UNUserNotificationCenter.Current.RequestAuthorization (Correct answer)
- NotificationManager.RequestPermission
- UIApplication.RegisterForRemoteNotifications
- PushNotification.RequestAccess
Correct answer: UNUserNotificationCenter.Current.RequestAuthorization
UNUserNotificationCenter.Current.RequestAuthorization is the modern API for requesting notification permissions on iOS.
Question 5: What does the Linker do in a Xamarin.iOS release build?
- Removes unused code to reduce app size (Correct answer)
- Links native Objective-C libraries
- Compiles IL to native code
- Connects to the App Store
Correct answer: Removes unused code to reduce app size
The Xamarin.iOS linker performs static analysis to strip unused managed code, reducing the final binary size.
Question 6: In Xamarin.iOS, which compilation mode converts IL to native ARM code ahead of time?
- AOT (Ahead-of-Time) (Correct answer)
- JIT (Just-in-Time)
- Interpreter
- LLVM Only
Correct answer: AOT (Ahead-of-Time)
iOS requires AOT compilation because Apple does not allow JIT execution on device.
Which Xamarin.iOS method is called when the app moves to the background?