Unit 6: Web Services - Practice Quiz

INT372 — Iphone Application Programming 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 Which framework is primarily used to display interactive maps in an iPhone application?

Displaying maps and monitoring changes using MapKit Framework Easy
A. SpriteKit
B. MapKit
C. CloudKit
D. UIKit

2 Which MapKit class displays a map in an iOS user interface?

Displaying maps and monitoring changes using MapKit Framework Easy
A. MKMapItem
B. MKMapPoint
C. MKMapView
D. MKRoute

3 Which protocol is commonly implemented to respond to events from an MKMapView?

Displaying maps and monitoring changes using MapKit Framework Easy
A. MKLocationDelegate
B. MKRouteDelegate
C. MKOverlayDelegate
D. MKMapViewDelegate

4 Which MKMapView property is enabled to display the user's current location?

Displaying maps and monitoring changes using MapKit Framework Easy
A. usesDeviceLocation
B. showsUserLocation
C. displaysCurrentPlace
D. tracksUserPosition

5 Which structure represents a geographic coordinate using latitude and longitude?

Displaying maps and monitoring changes using MapKit Framework Easy
A. CLLocationCoordinate2D
B. MKCoordinateSpan
C. MKCoordinateRegion
D. MKMapRect

6 Which MapKit type describes the visible region of a map using a center and a span?

Displaying maps and monitoring changes using MapKit Framework Easy
A. MKPointOfInterestFilter
B. MKCoordinateRegion
C. MKMapCamera
D. MKMapItem

7 Which method changes the visible region of an MKMapView?

Displaying maps and monitoring changes using MapKit Framework Easy
A. setRoute(_:animated:)
B. setOverlay(_:animated:)
C. setLocation(_:animated:)
D. setRegion(_:animated:)

8 Which delegate method is called after the visible map region changes?

Displaying maps and monitoring changes using MapKit Framework Easy
A. mapViewWillStartLoadingMap(_:)
B. mapViewDidFinishLoadingMap(_:)
C. mapView(_:regionDidChangeAnimated:)
D. mapViewDidStopLocatingUser(_:)

9 What is an annotation commonly used for in MapKit?

Displaying maps and monitoring changes using MapKit Framework Easy
A. Downloading a web page
B. Marking a map location
C. Storing an image file
D. Formatting a text field

10 Which method adds a single annotation to an MKMapView?

Displaying maps and monitoring changes using MapKit Framework Easy
A. registerCoordinate(_:)
B. addAnnotation(_:)
C. insertLocation(_:)
D. appendMarker(_:)

11 Which framework provides the WKWebView class?

WKWebView Easy
A. AVFoundation
B. WebKit
C. CoreData
D. MapKit

12 What is the main purpose of WKWebView in an iOS application?

WKWebView Easy
A. Showing map routes
B. Recording audio clips
C. Managing local databases
D. Displaying web content

13 Which object is commonly passed to WKWebView.load(_:) to load a web address?

WKWebView Easy
A. URLRequest
B. URLSession
C. URLResponse
D. URLCredential

14 Which method loads an HTML string directly into a WKWebView?

WKWebView Easy
A. loadFileURL(_:allowingReadAccessTo:)
B. setMagnification(_:centeredAt:)
C. evaluateJavaScript(_:completionHandler:)
D. loadHTMLString(_:baseURL:)

15 Which protocol receives navigation events from a WKWebView?

WKWebView Easy
A. WKNavigationDelegate
B. WKUIDelegate
C. WKURLSchemeHandler
D. WKScriptMessageHandler

16 Which WKWebView property is set to monitor web navigation events?

WKWebView Easy
A. scrollView
B. navigationDelegate
C. uiDelegate
D. configuration

17 Which method reloads the current page in a WKWebView?

WKWebView Easy
A. restart()
B. refresh()
C. reload()
D. update()

18 Which method navigates a WKWebView to the previous page in its history?

WKWebView Easy
A. goBack()
B. stopLoading()
C. reload()
D. goForward()

19 Which property indicates whether a WKWebView can navigate to a previous page?

WKWebView Easy
A. canGoForward
B. estimatedProgress
C. isLoading
D. canGoBack

20 Which WKWebView property indicates whether web content is currently loading?

WKWebView Easy
A. isLoading
B. hasOnlySecureContent
C. canGoBack
D. allowsLinkPreview

21 An app must detect when the user finishes panning or zooming an MKMapView. Which delegate method should it implement?

Displaying maps and monitoring changes using MapKit Framework Medium
A. mapView(_:regionDidChangeAnimated:)
B. mapViewDidFinishLoadingMap(_:)
C. mapView(_:didSelect:)
D. mapViewWillStartLoadingMap(_:)

22 A map should initially display a coordinate with a specified latitude and longitude span. Which value should be passed to setRegion(_:animated:)?

Displaying maps and monitoring changes using MapKit Framework Medium
A. An MKCoordinateRegion
B. An MKMapCamera configured with a tracking button and a delegate
C. An MKPointAnnotation
D. An MKMapRect

23 An app sets mapView.showsUserLocation = true, but the user's location does not appear. What is the most likely missing requirement?

Displaying maps and monitoring changes using MapKit Framework Medium
A. Location authorization and a usage description
B. A geocoding request for the user's current postal address before enabling the location layer
C. A map renderer delegate
D. A custom annotation view

24 A developer wants to display a pin for a restaurant without creating a custom annotation class. Which object is most appropriate?

Displaying maps and monitoring changes using MapKit Framework Medium
A. MKMapItem
B. MKPolyline
C. MKCoordinateRegion
D. MKPointAnnotation

25 A route is added to a map using mapView.addOverlay(route.polyline), but no line is visible. Which implementation is also required?

Displaying maps and monitoring changes using MapKit Framework Medium
A. Return an MKPolylineRenderer from the overlay renderer delegate method
B. Set the map's region inside every location update callback
C. Return an MKMarkerAnnotationView from the annotation view delegate method
D. Convert the route into an MKPointAnnotation before adding it

26 Which approach efficiently reuses annotation views when many annotations are displayed?

Displaying maps and monitoring changes using MapKit Framework Medium
A. Dequeue a reusable annotation view with an identifier
B. Create a new annotation view during every region change
C. Store one annotation view inside each coordinate value
D. Remove all annotations and recreate their views whenever the map finishes rendering

27 An app should continuously keep the map centered on the user's movement. Which MapKit feature best matches this requirement?

Displaying maps and monitoring changes using MapKit Framework Medium
A. Set isPitchEnabled to false
B. Set userTrackingMode to .follow
C. Set mapType to .standard
D. Call 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?

Displaying maps and monitoring changes using MapKit Framework Medium
A. Call showAnnotations(_:animated:)
B. Create a new region using a world-sized latitude and longitude span
C. Replace the map's camera with its default value
D. Call 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?

Displaying maps and monitoring changes using MapKit Framework Medium
A. MKMapView.setRegion(_:animated:)
B. MKLocalSearch.start(completionHandler:)
C. CLLocationManager.startMonitoring(for:)
D. 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?

Displaying maps and monitoring changes using MapKit Framework Medium
A. In mapView(_:viewFor:), after configuring every visible annotation view
B. In mapView(_:didAdd:)
C. In mapView(_:regionDidChangeAnimated:)
D. In mapViewWillStartRenderingMap(_:)

31 A WKWebView must open only links from example.com and cancel navigation to other hosts. Which API should be used?

WKWebView Medium
A. WKNavigationDelegate policy decisions
B. URLSessionDelegate authentication callbacks
C. WKUIDelegate JavaScript panels
D. WKScriptMessageHandler body inspection

32 A web view needs a JavaScript message handler named nativeApp. When must it be added to the WKUserContentController?

WKWebView Medium
A. After the first page finishes loading
B. Only after JavaScript calls the handler once and the web view reports an error
C. Before creating the web view with its configuration
D. Inside every navigation policy callback

33 Which JavaScript expression sends the string ready to a registered native message handler named nativeApp?

WKWebView Medium
A. document.messageHandlers.nativeApp.post('ready')
B. webkit.nativeApp.evaluateJavaScript('ready')
C. window.nativeApp.sendMessage('ready')
D. 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?

WKWebView Medium
A. App Transport Security restrictions
B. A missing JavaScript message handler
C. A disabled back-forward navigation gesture
D. An absent WKUIDelegate

35 A controller wants to retrieve document.title after a page loads. Which method should it call?

WKWebView Medium
A. reloadFromOrigin()
B. goBack()
C. evaluateJavaScript(_:completionHandler:)
D. 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?

WKWebView Medium
A. Use go(to:) with a newly created back-forward list item
B. Use loadHTMLString(_:baseURL:) with a nil base URL
C. Use evaluateJavaScript(_:completionHandler:) to convert the image into a navigation request
D. Use 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?

WKWebView Medium
A. webView(_:didCommit:)
B. userContentController(_:didReceive:)
C. webView(_:didReceive:completionHandler:)
D. 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?

WKWebView Medium
A. Set the navigation delegate to the controller again after each page load
B. Disable JavaScript before removing the controller's root view
C. Clear the web view's back-forward list before dismissal
D. Remove the script message handler when it is no longer needed

39 A page's loading indicator should stop only when navigation completes successfully. Which callback should update the indicator?

WKWebView Medium
A. webViewWebContentProcessDidTerminate(_:)
B. webView(_:didFinish:)
C. webView(_:decidePolicyFor:decisionHandler:)
D. webView(_:didStartProvisionalNavigation:)

40 Two WKWebView instances need to share cookies and other website data. Which configuration choice supports this?

WKWebView Medium
A. Use the same persistent WKWebsiteDataStore
B. Use identical custom user-agent strings and reload both pages after each navigation
C. Use separate nonpersistent data stores
D. Use the same 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?

Displaying maps and monitoring changes using MapKit Framework Hard
A. Update the indicator in mapView(_:didUpdate:) and query in mapView(_:regionWillChangeAnimated:)
B. Update the indicator in mapView(_:regionWillChangeAnimated:) and query in mapViewDidFinishRenderingMap(_:fullyRendered:)
C. Update the indicator in mapViewDidFinishLoadingMap(_:) and query in mapViewDidChangeVisibleRegion(_:)
D. Update the indicator in 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?

Displaying maps and monitoring changes using MapKit Framework Hard
A. Set isZoomEnabled to false before every programmatic region update
B. Move every correction into mapViewDidFinishRenderingMap(_:fullyRendered:)
C. Replace setRegion with showAnnotations(_:animated:) for all corrections
D. Compare using a tolerance and suppress callbacks while applying the programmatic correction

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?

Displaying maps and monitoring changes using MapKit Framework Hard
A. Convert all point annotations into a single MKMultiPoint overlay
B. Assign a non-nil shared clusteringIdentifier when configuring each reusable annotation view
C. Set collisionMode to .rectangle only after the region stops changing
D. Assign a unique 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?

Displaying maps and monitoring changes using MapKit Framework Hard
A. Register the polyline using register(_:forAnnotationViewWithReuseIdentifier:)
B. Convert the overlay coordinates into CLLocation objects before rendering
C. Return an MKPolylineRenderer for the overlay from mapView(_:rendererFor:)
D. Return an 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?

Displaying maps and monitoring changes using MapKit Framework Hard
A. The map center remains fixed until showsUserLocation is explicitly disabled
B. The visible center is always expressed in screen points rather than geographic coordinates
C. User tracking prevents MKMapView from receiving Core Location position updates
D. Camera animations and insets can make the visible center differ from 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?

Displaying maps and monitoring changes using MapKit Framework Hard
A. Compare the textual descriptions returned by both coordinate regions
B. Compare only the latitude spans because longitude wrapping is automatic
C. Compare only the absolute longitude difference between the two region centers
D. Compare normalized 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?

Displaying maps and monitoring changes using MapKit Framework Hard
A. Create one reuse identifier and configure properties only during allocation
B. Reset every type-dependent property whenever a dequeued view is configured
C. Remove and re-add every annotation whenever the visible region changes
D. Disable annotation selection before returning each reused annotation view

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?

Displaying maps and monitoring changes using MapKit Framework Hard
A. MapKit constrains the resulting camera to satisfy the configured boundary and zoom range
B. MapKit applies the boundary but permanently removes the zoom restriction
C. MapKit rejects the request by throwing an Objective-C exception
D. MapKit ignores both restrictions whenever the camera transition is animated

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?

Displaying maps and monitoring changes using MapKit Framework Hard
A. The map has converted the location into a coordinate and discarded the fix
B. Location authorization has necessarily been denied permanently by the user
C. The user-location annotation exists, but a valid location fix is not yet available
D. The delegate callback guarantees that only heading information is available

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?

Displaying maps and monitoring changes using MapKit Framework Hard
A. Execute every request synchronously from the map delegate on the main thread
B. Call setNeedsDisplay() before applying every server response to the map
C. Cancel prior requests or associate each response with the latest region-generation token
D. Ignore the 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?

WKWebView Hard
A. The decisionHandler was not invoked exactly once on every execution path
B. The navigation delegate did not implement the response-policy method as well
C. The navigation action was not converted into an NSMutableURLRequest
D. The web view was not reloaded before returning .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?

WKWebView Hard
A. Call reloadFromOrigin() and return a newly allocated hidden web view
B. Call webView.load(navigationAction.request) and return nil from the creation callback
C. Return the existing webView directly from the creation callback
D. Create an 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?

WKWebView Hard
A. WKNavigationDelegate always retains its delegate until the process terminates
B. WKUserContentController retains its script message handler until it is removed
C. WKWebView permanently retains every view controller that loads JavaScript
D. 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?

WKWebView Hard
A. Different content worlds have separate JavaScript global-object environments
B. Scripts in isolated worlds execute only after the web view has been deallocated
C. Page JavaScript can access isolated variables only when cookies are disabled
D. The helper variable is automatically converted into a native Swift property

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?

WKWebView Hard
A. Convert each relative resource URL into an unrestricted http URL
B. Store the resources in UserDefaults before loading the HTML document
C. Grant read access to the app's executable file instead of the resource directory
D. Grant read access to the containing directory that holds the required resources

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?

WKWebView Hard
A. webView(_:didFinish:)
B. webView(_:didFail:withError:)
C. webViewWebContentProcessDidTerminate(_:)
D. 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?

WKWebView Hard
A. Assign different navigation delegates while sharing one persistent data store
B. Assign distinct persistent WKWebsiteDataStore instances created with different identifiers
C. Assign the same WKProcessPool and clear only each web view's back-forward list
D. Assign different 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?

WKWebView Hard
A. Scheme handlers can intercept https only when the web view uses nonpersistent storage
B. Scheme handlers require https responses to be converted into local file URLs
C. Custom scheme handlers cannot replace WebKit's built-in handling of standard schemes such as https
D. Scheme handlers can intercept 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?

WKWebView Hard
A. Pass the value through a structured JavaScript argument API or JSON-encode it before evaluation
B. Percent-encode the value as a URL and concatenate it without JavaScript decoding
C. Wrap the value in an HTML comment before inserting it into the JavaScript expression
D. Remove only single quotation marks and continue constructing the JavaScript source

60 A web content process terminates while a form page is open. The app receives webViewWebContentProcessDidTerminate(_:). Which recovery assumption is unsafe?

WKWebView Hard
A. The callback indicates process loss rather than an ordinary HTTP navigation error
B. The app may offer a reload while preserving native state outside the web process
C. Calling reload() will necessarily restore unsaved JavaScript and form state
D. Critical draft data should be persisted outside volatile page memory when possible