Unit 6: Web Services - Practice Quiz
1 Which framework is primarily used to display interactive maps in an iPhone application?
2 Which MapKit class displays a map in an iOS user interface?
3
Which protocol is commonly implemented to respond to events from an MKMapView?
4
Which MKMapView property is enabled to display the user's current location?
5 Which structure represents a geographic coordinate using latitude and longitude?
6 Which MapKit type describes the visible region of a map using a center and a span?
7
Which method changes the visible region of an MKMapView?
8 Which delegate method is called after the visible map region changes?
9 What is an annotation commonly used for in MapKit?
10
Which method adds a single annotation to an MKMapView?
11
Which framework provides the WKWebView class?
12
What is the main purpose of WKWebView in an iOS application?
13
Which object is commonly passed to WKWebView.load(_:) to load a web address?
14
Which method loads an HTML string directly into a WKWebView?
15
Which protocol receives navigation events from a WKWebView?
16
Which WKWebView property is set to monitor web navigation events?
17
Which method reloads the current page in a WKWebView?
18
Which method navigates a WKWebView to the previous page in its history?
19
Which property indicates whether a WKWebView can navigate to a previous page?
20
Which WKWebView property indicates whether web content is currently loading?
21
An app must detect when the user finishes panning or zooming an MKMapView. Which delegate method should it implement?
mapView(_:regionDidChangeAnimated:)
mapViewDidFinishLoadingMap(_:)
mapView(_:didSelect:)
mapViewWillStartLoadingMap(_:)
22
A map should initially display a coordinate with a specified latitude and longitude span. Which value should be passed to setRegion(_:animated:)?
MKCoordinateRegion
MKMapCamera configured with a tracking button and a delegate
MKPointAnnotation
MKMapRect
23
An app sets mapView.showsUserLocation = true, but the user's location does not appear. What is the most likely missing requirement?
24 A developer wants to display a pin for a restaurant without creating a custom annotation class. Which object is most appropriate?
MKMapItem
MKPolyline
MKCoordinateRegion
MKPointAnnotation
25
A route is added to a map using mapView.addOverlay(route.polyline), but no line is visible. Which implementation is also required?
MKPolylineRenderer from the overlay renderer delegate method
MKMarkerAnnotationView from the annotation view delegate method
MKPointAnnotation before adding it
26 Which approach efficiently reuses annotation views when many annotations are displayed?
27 An app should continuously keep the map centered on the user's movement. Which MapKit feature best matches this requirement?
isPitchEnabled to false
userTrackingMode to .follow
mapType to .standard
showAnnotations(_:animated:) after adding a fixed annotation
28 A map update should preserve the current zoom level while moving the center to a new coordinate. Which operation is most suitable?
showAnnotations(_:animated:)
camera with its default value
setCenter(_:animated:)
29 An app monitors entry into and exit from a circular geographic area, including while it is not displaying the map. Which API is intended for this task?
MKMapView.setRegion(_:animated:)
MKLocalSearch.start(completionHandler:)
CLLocationManager.startMonitoring(for:)
MKMapView.addOverlay(_:level:)
30 A developer receives frequent callbacks while the map is being dragged and wants to begin an expensive search only after movement ends. Where should the search be triggered?
mapView(_:viewFor:), after configuring every visible annotation view
mapView(_:didAdd:)
mapView(_:regionDidChangeAnimated:)
mapViewWillStartRenderingMap(_:)
31
A WKWebView must open only links from example.com and cancel navigation to other hosts. Which API should be used?
WKNavigationDelegate policy decisions
URLSessionDelegate authentication callbacks
WKUIDelegate JavaScript panels
WKScriptMessageHandler body inspection
32
A web view needs a JavaScript message handler named nativeApp. When must it be added to the WKUserContentController?
33
Which JavaScript expression sends the string ready to a registered native message handler named nativeApp?
document.messageHandlers.nativeApp.post('ready')
webkit.nativeApp.evaluateJavaScript('ready')
window.nativeApp.sendMessage('ready')
window.webkit.messageHandlers.nativeApp.postMessage('ready')
34
An app calls webView.load(URLRequest(url: url)) with a plain http:// URL, but navigation is blocked on a default iOS configuration. What is the likely cause?
WKUIDelegate
35
A controller wants to retrieve document.title after a page loads. Which method should it call?
reloadFromOrigin()
goBack()
evaluateJavaScript(_:completionHandler:)
loadHTMLString(_:baseURL:)
36
Local HTML contains <img src="images/logo.png">, and the image must resolve relative to the HTML file's directory. Which loading approach is appropriate?
go(to:) with a newly created back-forward list item
loadHTMLString(_:baseURL:) with a nil base URL
evaluateJavaScript(_:completionHandler:) to convert the image into a navigation request
loadFileURL(_:allowingReadAccessTo:) with suitable directory access
37
A web page calls window.open(...), but no new content appears. Which delegate method is commonly implemented to handle requests for a new web view?
webView(_:didCommit:)
userContentController(_:didReceive:)
webView(_:didReceive:completionHandler:)
webView(_:createWebViewWith:for:windowFeatures:)
38 A view controller registers itself as a script message handler and remains in memory after dismissal. Which change most directly addresses the common retention problem?
39 A page's loading indicator should stop only when navigation completes successfully. Which callback should update the indicator?
webViewWebContentProcessDidTerminate(_:)
webView(_:didFinish:)
webView(_:decidePolicyFor:decisionHandler:)
webView(_:didStartProvisionalNavigation:)
40
Two WKWebView instances need to share cookies and other website data. Which configuration choice supports this?
WKWebsiteDataStore
WKNavigationDelegate
41 A controller must update a lightweight scale indicator continuously while the user pans, but perform an expensive server query only after the map movement finishes. Which delegate-method pairing is most appropriate?
mapView(_:didUpdate:) and query in mapView(_:regionWillChangeAnimated:)
mapView(_:regionWillChangeAnimated:) and query in mapViewDidFinishRenderingMap(_:fullyRendered:)
mapViewDidFinishLoadingMap(_:) and query in mapViewDidChangeVisibleRegion(_:)
mapViewDidChangeVisibleRegion(_:) and query in mapView(_:regionDidChangeAnimated:)
42
An app calls setRegion(_:animated:) inside mapView(_:regionDidChangeAnimated:) whenever the center differs slightly from a desired coordinate. Users observe repeated delegate callbacks and camera jitter. What is the best correction?
isZoomEnabled to false before every programmatic region update
mapViewDidFinishRenderingMap(_:fullyRendered:)
setRegion with showAnnotations(_:animated:) for all corrections
43
A map shows thousands of point annotations. Clustering is enabled, but no clusters appear even when many annotations overlap. The delegate creates a new MKMarkerAnnotationView and assigns clusteringIdentifier only after the view has been displayed. Which change most directly fixes the issue?
MKMultiPoint overlay
nil shared clusteringIdentifier when configuring each reusable annotation view
collisionMode to .rectangle only after the region stops changing
clusteringIdentifier to every annotation before adding it
44
An app displays a geodesic flight path using MKGeodesicPolyline, but the path is invisible. The overlay is successfully added and intersects the visible map rectangle. Which missing implementation is the most likely cause?
register(_:forAnnotationViewWithReuseIdentifier:)
CLLocation objects before rendering
MKPolylineRenderer for the overlay from mapView(_:rendererFor:)
MKMarkerAnnotationView for the overlay from mapView(_:viewFor:)
45
A map-based app needs the user's actual location for business logic. It currently treats the center of the map while .follow tracking mode is active as the user's position. Why is this unreliable?
showsUserLocation is explicitly disabled
MKMapView from receiving Core Location position updates
userLocation.location
46
A search request should run after a pan ends, but only when the newly visible area is meaningfully different. Comparing MKCoordinateRegion spans causes errors near the International Date Line. Which comparison is more robust?
MKMapRect coverage and handle world-map wrapping explicitly
47
A map uses mapView(_:viewFor:) to configure reusable annotation views. After reuse, some ordinary annotations display stale callout accessory controls that belong to other annotation types. Which practice prevents this defect?
48
An app sets both an MKMapView.CameraBoundary and an MKMapView.CameraZoomRange. It then requests an animated camera outside the boundary and below the minimum center-coordinate distance. What should the app assume?
49
A controller listens to mapView(_:didUpdate:) for user-location updates. Immediately after enabling showsUserLocation, the callback occurs, but userLocation.location is nil. What is the correct interpretation?
50
An app reloads visible data whenever mapView(_:regionDidChangeAnimated:) is called. During a rapid sequence of pans, responses arrive out of order and older results replace newer ones. Which design best preserves correctness?
setNeedsDisplay() before applying every server response to the map
animated argument and accept responses in completion order
51
In webView(_:decidePolicyFor:decisionHandler:), an app asynchronously checks whether a URL is allowed. Some navigations hang indefinitely. Which contract was most likely violated?
decisionHandler was not invoked exactly once on every execution path
NSMutableURLRequest
.allow asynchronously
52
JavaScript calls window.open(url), and the navigation action received by the UI delegate has targetFrame == nil. The app wants the URL to load in the same web view. Which implementation is appropriate?
reloadFromOrigin() and return a newly allocated hidden web view
webView.load(navigationAction.request) and return nil from the creation callback
webView directly from the creation callback
SFSafariViewController and return it as a WKWebView
53
A view controller registers itself using userContentController.add(self, name: "bridge"). After the web view is dismissed, the controller never deinitializes. What is the most likely ownership problem?
WKNavigationDelegate always retains its delegate until the process terminates
WKUserContentController retains its script message handler until it is removed
WKWebView permanently retains every view controller that loads JavaScript
WKWebsiteDataStore retains the presenting navigation controller by design
54
An app injects a helper script into an isolated WKContentWorld. The page's own JavaScript cannot read a variable created by that script, although both execute in the same frame. What best explains this behavior?
55
A bundled HTML file loads successfully with loadFileURL(_:allowingReadAccessTo:), but its sibling CSS and image files fail. The read-access URL was set to the HTML file itself. What is the correct fix?
http URL
UserDefaults before loading the HTML document
56 A top-level request receives an HTTP redirect and then fails before any document is committed. Which delegate callback should handle this failure rather than a failure occurring after content has started loading?
webView(_:didFinish:)
webView(_:didFail:withError:)
webViewWebContentProcessDidTerminate(_:)
webView(_:didFailProvisionalNavigation:withError:)
57
Two WKWebView instances must have completely separate persistent cookies and caches, even across app launches. Which configuration choice most directly establishes that separation?
WKWebsiteDataStore instances created with different identifiers
WKProcessPool and clear only each web view's back-forward list
customUserAgent values while sharing the default data store
58
An app registers a WKURLSchemeHandler and attempts to intercept normal https requests by registering it for the https scheme. What is the fundamental problem?
https only when the web view uses nonpersistent storage
https responses to be converted into local file URLs
https
https only after the first navigation has committed
59
A WKWebView displays a user-controlled page. The app injects the user's raw name into evaluateJavaScript using window.setName('\(name)'). Names containing quotes break execution, and crafted names can execute code. Which approach is safest?
60
A web content process terminates while a form page is open. The app receives webViewWebContentProcessDidTerminate(_:). Which recovery assumption is unsafe?
reload() will necessarily restore unsaved JavaScript and form state
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →