---
title: "One Swift mistake everyone should stop making today"
url: https://daily.dev/posts/one-swift-mistake-everyone-should-stop-making-today-fw07jmw6y
source_url: https://www.hackingwithswift.com/articles/280/one-swift-mistake-everyone-should-stop-making-today
type: article
source: "Hacking with Swift"
published: 2025-11-10T20:57:32.597Z
updated: 2025-11-10T20:57:54.338Z
tags: ["ios", "swift", "objective-c"]
reading_time: 4
upvotes: 1
comments: 0
language: 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.

# One Swift mistake everyone should stop making today

**[Hacking with Swift](https://daily.dev/sources/hackingwithswift)** · 4 min read · 1 upvotes · 0 comments

## Summary

Swift developers should use the native replacing(_:with:) method instead of replacingOccurrences(of:with:) to avoid Unicode-related bugs. The Objective-C method replacingOccurrences doesn't handle Unicode properly, particularly with emoji flags composed of regional indicator symbols. This can cause bizarre string mutations where replacing non-existent characters produces unexpected results. The Swift-native replacing method honors Unicode fully, is shorter to write, and likely faster.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.hackingwithswift.com/articles/280/one-swift-mistake-everyone-should-stop-making-today>

## Similar posts on daily.dev

- [My Favorite Bugs: Invalid Surrogate Pairs](https://daily.dev/posts/my-favorite-bugs-invalid-surrogate-pairs-qzculkzdx) · Hacker News · 0 upvotes · 0 comments

---

Tags: [#ios](https://daily.dev/tags/ios), [#swift](https://daily.dev/tags/swift), [#objective-c](https://daily.dev/tags/objective-c)

[View this post on daily.dev](https://daily.dev/posts/one-swift-mistake-everyone-should-stop-making-today-fw07jmw6y)
