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. MapKit
B. CloudKit
C. SpriteKit
D. UIKit

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

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

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. tracksUserPosition
C. showsUserLocation
D. displaysCurrentPlace

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

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

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. MKMapItem
D. MKMapCamera

7 Which method changes the visible region of an MKMapView?

Displaying maps and monitoring changes using MapKit Framework Easy
A. setRoute(_:animated:)
B. setLocation(_:animated:)
C. setOverlay(_: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. mapViewDidFinishLoadingMap(_:)
B. mapViewWillStartLoadingMap(_:)
C. mapViewDidStopLocatingUser(_:)
D. mapView(_:regionDidChangeAnimated:)

9 What is an annotation commonly used for in MapKit?

Displaying maps and monitoring changes using MapKit Framework Easy
A. Storing an image file
B. Marking a map location
C. Downloading a web page
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. addAnnotation(_:)
B. appendMarker(_:)
C. insertLocation(_:)
D. registerCoordinate(_:)

11 Which framework provides the WKWebView class?

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

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

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

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

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

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

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

15 Which protocol receives navigation events from a WKWebView?

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

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

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

17 Which method reloads the current page in a WKWebView?

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

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

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

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

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

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

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

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. mapViewWillStartLoadingMap(_:)
B. mapView(_:regionDidChangeAnimated:)
C. mapViewDidFinishLoadingMap(_:)
D. mapView(_:didSelect:)

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 MKMapCamera configured with a tracking button and a delegate
B. An MKMapRect
C. An MKPointAnnotation
D. An MKCoordinateRegion

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. A map renderer delegate
B. A custom annotation view
C. A geocoding request for the user's current postal address before enabling the location layer
D. Location authorization and a usage description

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. MKPointAnnotation
B. MKPolyline
C. MKMapItem
D. MKCoordinateRegion

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. Return an MKMarkerAnnotationView from the annotation view delegate method
C. Set the map's region inside every location update callback
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. Remove all annotations and recreate their views whenever the map finishes rendering
B. Create a new annotation view during every region change
C. Dequeue a reusable annotation view with an identifier
D. Store one annotation view inside each coordinate value

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. Call showAnnotations(_:animated:) after adding a fixed annotation
D. Set mapType to .standard

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

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. CLLocationManager.startMonitoring(for:)
B. MKMapView.addOverlay(_:level:)
C. MKMapView.setRegion(_:animated:)
D. MKLocalSearch.start(completionHandler:)

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(_:regionDidChangeAnimated:)
B. In mapView(_:viewFor:), after configuring every visible annotation view
C. In mapViewWillStartRenderingMap(_:)
D. In mapView(_:didAdd:)

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. WKUIDelegate JavaScript panels
C. URLSessionDelegate authentication callbacks
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. window.nativeApp.sendMessage('ready')
B. document.messageHandlers.nativeApp.post('ready')
C. window.webkit.messageHandlers.nativeApp.postMessage('ready')
D. webkit.nativeApp.evaluateJavaScript('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 disabled back-forward navigation gesture
C. A missing JavaScript message handler
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 evaluateJavaScript(_:completionHandler:) to convert the image into a navigation request
B. Use loadFileURL(_:allowingReadAccessTo:) with suitable directory access
C. Use go(to:) with a newly created back-forward list item
D. Use loadHTMLString(_:baseURL:) with a nil base URL

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. userContentController(_:didReceive:)
B. webView(_:didCommit:)
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. Remove the script message handler when it is no longer needed
B. Disable JavaScript before removing the controller's root view
C. Clear the web view's back-forward list before dismissal
D. Set the navigation delegate to the controller again after each page load

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

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

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 the same WKNavigationDelegate
D. Use separate nonpersistent data stores

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 mapViewDidChangeVisibleRegion(_:) and query in mapView(_:regionDidChangeAnimated:)
C. Update the indicator in mapViewDidFinishLoadingMap(_:) and query in mapViewDidChangeVisibleRegion(_:)
D. Update the indicator in mapView(_:regionWillChangeAnimated:) and query in mapViewDidFinishRenderingMap(_:fullyRendered:)

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. Replace setRegion with showAnnotations(_:animated:) for all corrections
B. Compare using a tolerance and suppress callbacks while applying the programmatic correction
C. Move every correction into mapViewDidFinishRenderingMap(_:fullyRendered:)
D. Set isZoomEnabled to false before every programmatic region update

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. Assign a unique clusteringIdentifier to every annotation before adding it
B. Set collisionMode to .rectangle only after the region stops changing
C. Assign a non-nil shared clusteringIdentifier when configuring each reusable annotation view
D. Convert all point annotations into a single MKMultiPoint overlay

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. Return an MKMarkerAnnotationView for the overlay from mapView(_:viewFor:)
C. Convert the overlay coordinates into CLLocation objects before rendering
D. Return an MKPolylineRenderer for the overlay from mapView(_:rendererFor:)

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

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 only the absolute longitude difference between the two region centers
B. Compare normalized MKMapRect coverage and handle world-map wrapping explicitly
C. Compare the textual descriptions returned by both coordinate regions
D. Compare only the latitude spans because longitude wrapping is automatic

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. Disable annotation selection before returning each reused annotation view
C. Reset every type-dependent property whenever a dequeued view is configured
D. Remove and re-add every annotation whenever the visible region changes

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 rejects the request by throwing an Objective-C exception
B. MapKit ignores both restrictions whenever the camera transition is animated
C. MapKit applies the boundary but permanently removes the zoom restriction
D. MapKit constrains the resulting camera to satisfy the configured boundary and zoom range

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. Location authorization has necessarily been denied permanently by the user
B. The user-location annotation exists, but a valid location fix is not yet available
C. The map has converted the location into a coordinate and discarded the fix
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. Call setNeedsDisplay() before applying every server response to the map
B. Ignore the animated argument and accept responses in completion order
C. Execute every request synchronously from the map delegate on the main thread
D. Cancel prior requests or associate each response with the latest region-generation token

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

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. Return the existing webView directly from the creation callback
C. Call webView.load(navigationAction.request) and return nil 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. WKWebView permanently retains every view controller that loads JavaScript
B. WKUserContentController retains its script message handler until it is removed
C. WKNavigationDelegate always retains its delegate until the process terminates
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. The helper variable is automatically converted into a native Swift property
B. Different content worlds have separate JavaScript global-object environments
C. Scripts in isolated worlds execute only after the web view has been deallocated
D. Page JavaScript can access isolated variables only when cookies are disabled

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. webViewWebContentProcessDidTerminate(_:)
B. webView(_:didFinish:)
C. webView(_:didFail:withError:)
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 different customUserAgent values while sharing the default data store
C. Assign distinct persistent WKWebsiteDataStore instances created with different identifiers
D. Assign the same WKProcessPool and clear only each web view's back-forward list

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

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. Percent-encode the value as a URL and concatenate it without JavaScript decoding
B. Pass the value through a structured JavaScript argument API or JSON-encode it before evaluation
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. Critical draft data should be persisted outside volatile page memory when possible
B. The app may offer a reload while preserving native state outside the web process
C. The callback indicates process loss rather than an ordinary HTTP navigation error
D. Calling reload() will necessarily restore unsaved JavaScript and form state