<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/tracking-value-sources-to-prevent-recursive-swiftui-updates-opiijshln" -->

---
title: Tracking value sources to prevent recursive SwiftUI updates
description: When wrapping UITextView or NSTextView in SwiftUI, writing user input back to a binding triggers a redundant update cycle. The common fix — comparing strings...
canonical: https://daily.dev/posts/tracking-value-sources-to-prevent-recursive-swiftui-updates-opiijshln
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Tracking value sources to prevent recursive SwiftUI updates | daily.dev
og:description: When wrapping UITextView or NSTextView in SwiftUI, writing user input back to a binding triggers a redundant update cycle. The common fix — comparing strings...
og:url: https://daily.dev/posts/tracking-value-sources-to-prevent-recursive-swiftui-updates-opiijshln
og:image: https://api.daily.dev/og/posts/opIIjSHLN.png
og:image:alt: Tracking value sources to prevent recursive SwiftUI updates
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Tracking value sources to prevent recursive SwiftUI updates

**[Nil Coalescing](https://daily.dev/sources/nilcoalescing)** · 3 min read · 0 upvotes · 0 comments

## Summary

When wrapping UITextView or NSTextView in SwiftUI, writing user input back to a binding triggers a redundant update cycle. The common fix — comparing strings before applying updates — is expensive for large text. A better approach uses SwiftUI's transaction system to tag updates with an ObjectIdentifier of the originating text view. In updateUIView/updateNSView, the wrapper checks the transaction's custom value and skips the update if it originated from that same view. The custom transaction value is declared via the @Entry macro in a Transaction extension. This pattern generalizes to any UIView/NSView with gesture-driven state that feeds back into SwiftUI.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://nilcoalescing.com/blog/TrackingValueSourcesToPreventRecursiveSwiftUIUpdates>

## Similar posts on daily.dev

- [SwiftUI data dependencies and their effect on view updates](https://daily.dev/posts/swiftui-data-dependencies-and-their-effect-on-view-updates-2kp42i6if) · Nil Coalescing · 1 upvotes · 0 comments
- [Two Files. One Difference. An 11× Bill You Never See.](https://daily.dev/posts/two-files-one-difference-an-11-bill-you-never-see--ei9uyurk1) · Medium · 0 upvotes · 0 comments
- [Why Child @State Won't Update from Parent in SwiftUI](https://daily.dev/posts/why-child-state-won-t-update-from-parent-in-swiftui-o7btsoihp) · Fatbobman · 0 upvotes · 0 comments
- [Who Told The View To Update?](https://daily.dev/posts/who-told-the-view-to-update--xvxtydysb) · Medium · 0 upvotes · 0 comments

---

Tags: [#swift](https://daily.dev/tags/swift), [#swiftui](https://daily.dev/tags/swiftui)

[View this post on daily.dev](https://daily.dev/posts/tracking-value-sources-to-prevent-recursive-swiftui-updates-opiijshln)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Tracking value sources to prevent recursive SwiftUI updates","url":"https://daily.dev/posts/tracking-value-sources-to-prevent-recursive-swiftui-updates-opiijshln","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/tracking-value-sources-to-prevent-recursive-swiftui-updates-opiijshln"},"datePublished":"2026-08-04T10:09:54.264Z","dateModified":"2026-08-04T10:10:15.207Z","description":"When wrapping UITextView or NSTextView in SwiftUI, writing user input back to a binding triggers a redundant update cycle. The common fix — comparing strings...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/09f840d12716b936d1fb1aeb6f8625fd?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/09f840d12716b936d1fb1aeb6f8625fd?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Nil Coalescing","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Nil Coalescing","logo":"https://media.daily.dev/image/upload/s--rcEu6sag--/f_auto,q_auto/v1785654899/logos/nilcoalescing?_a=BAMAMicg0","url":"https://daily.dev/sources/nilcoalescing"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/tracking-value-sources-to-prevent-recursive-swiftui-updates-opiijshln","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"swift,swiftui","timeRequired":"PT3M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Nil Coalescing","item":"https://daily.dev/sources/nilcoalescing"},{"@type":"ListItem","position":3,"name":"Tracking value sources to prevent recursive SwiftUI updates"}]}
```

