Utils
public class Utils : NSObject
A utility class for handling various ad-related operations and conversions.
-
The class is created as a singleton object & used
Declaration
Swift
@objc public static let shared: Utils
-
A delegate to handle native ad events.
Declaration
Swift
@objc public weak var delegate: NativeAdDelegate?
-
Deprecated. MoPub is not available anymore. Use Prebid MAX adapters instead.
Declaration
Swift
@available(*, deprecated, message: "MoPub is not available anymore. Use Prebid MAX adapters instead.") @objc public func convertDictToMoPubKeywords(dict: Dictionary<String, String>) -> String
-
Finds a native ad object within a given object.
Declaration
Swift
@objc public func findNative(adObject: AnyObject)
Parameters
adObject
The object to search within.
-
Rounds geographic coordinates to a specified decimal precision.
This method rounds both latitude and longitude values to the specified number of decimal places. For example, with precision 2, coordinates (37.7749, -122.4194) become (37.77, -122.42).
Note
This method uses standard rounding rules (round half up). For example: - 37.775 rounds to 37.78 with precision 2 - 37.774 rounds to 37.77 with precision 2
Example:
let utils = Utils.shared let coords = CLLocationCoordinate2D(latitude: 37.7749, longitude: -122.4194) let rounded = utils.round(coordinates: coords, precision: NSNumber(value: 2)) // Result: latitude: 37.77, longitude: -122.42
Declaration
Swift
@objc public func round(coordinates: CLLocationCoordinate2D, precision: NSNumber?) -> CLLocationCoordinate2D
Parameters
coordinates
The geographic coordinates to round (latitude: -90 to 90, longitude: -180 to 180)
precision
The number of decimal places to round to. Must be non-negative. - 0: Round to whole numbers (e.g., 37.8 -> 38.0) - 1: Round to 1 decimal place (e.g., 37.7749 -> 37.8) - 2: Round to 2 decimal places (e.g., 37.7749 -> 37.77) - nil: Return original coordinates unchanged
Return Value
A new CLLocationCoordinate2D with rounded values, or the original coordinates if: - precision is nil - precision is negative - coordinates are invalid (outside valid ranges) - precision results in infinite or zero multiplier - rounded values are not finite