Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

[ios] Replace ornament margin assert with NSException (follow on to #13911) #14065

Closed

Description

@julianrex

Follow-on to PR #13911

Rather than asserting

NSAssert(CGRectContainsPoint(self.bounds, scaleBarOffset)

(e.g. https://github.com/mapbox/mapbox-gl-native/pull/13911/files#diff-20502b6bc02986a4398d0da84b2d4b94R827)

we should:

  • Raise an NSInvalidArgumentException.

    We typically use NSExceptions when alerting the developer of programmer error; in our release SDK, asserts will be "compiled out" (so will be a no-op). Asserts are useful for those developing the SDK itself.

  • As discussed, the margin (offset) is a vector quantity, not a point. Given that the margin is an inset from mgl_safeTopAnchor (and related anchors), it's possible to have a valid margin but the assert to fire. This check needs to take the anchors into consideration.

/cc @lloydsheng @friedbunny

Activity

  1. added
    iOS
    on Mar 8, 2019
  2. lloydsheng commented on Apr 9, 2019

    @lloydsheng
    Contributor

    @julianrex The purpose of those asserts is making sure ornaments in proper positions. Seems layoutSubviews is a good position to guard that. Here is my attempt #14373. Looking forward to your suggestions. 😊 cc: @chriswu42

  3. added this to the release-p milestone on Jun 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

iOSrefactor

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions