Skip to content

Commit

Permalink
Merge pull request #55 from sookim-1/feature/044_20241209
Browse files Browse the repository at this point in the history
Create 044-20241209.md
  • Loading branch information
sookim-1 authored Dec 10, 2024
2 parents 7a67cae + ddb3e5c commit 2681aec
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
54 changes: 54 additions & 0 deletions Content/en/044-20241209_en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
author: sookim-1
description: UITextField Copy and Paste, Impressions on Using Cursor AI, Medium Shortcuts, React Native Code Push End-of-Life
date: 2024-12-09 18:30
tags: iOS, Swift, Flutter, React Native, Blog, Cursor, UITextField
published: true
---
# Number : 044, Date: 2024-12-09
## 2024.12.02 ~ 2024.12.08
### ⌨️ Summary on TextField Copy-Paste

---

In iOS apps, `UITextField` can be used to receive text input from users.

Users can paste text into the `UITextField` instead of typing directly via the keyboard.

Here’s the sequence of operations that occur during pasting:

> Logic Sequence for Pasting
>
1. When pasting, the first method called is `shouldChangeCharactersIn`, a part of the `UITextFieldDelegate`.
- At this point, you can block pasting if any unwanted characters are detected through regex validation.
2. The `editingChanged` event then receives the input text.
- You can either display the received text as-is or process it before displaying.

> How to Prevent Pasting
>
```swift
class CustomTextField: UITextField {

open override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
if action == #selector(UIResponderStandardEditActions.paste(_:)) {
return false
}

return super.canPerformAction(action, withSender: sender)
}

...
```

You can prevent various actions, including pasting, by implementing the `UIResponderStandardEditActions` protocol.

### 🙋🏻‍♂️ Additional Notes

---

1. I attempted to use Cursor AI for tasks like converting an iOS project to a Flutter project or refactoring to a specific architectural pattern. My impression is that it understands SwiftUI code better than UIKit. It handles simple tasks like removing libraries such as SnapKit and Then and refactoring to basic implementations relatively well, but it's not yet reliable enough for full architectural refactoring.
2. I explored shortcuts and methods for writing articles after moving to Medium as my blogging platform.
3. React Native's Code Push will officially be retired in March 2025. Since Flutter now offers ShoreBird for code push functionality, Flutter seems to have an edge in this area as both platforms now require paid services.
- [Official Announcement on RN Code Push Retirement](https://learn.microsoft.com/ko-kr/appcenter/retirement)
- [Discussion on RN Code Push End-of-Life](https://www.linkedin.com/posts/cho-minkyu_discussion-visual-studio-app-center-retirement-activity-7249377764556881920-VcNr?utm_source=share&utm_medium=member_desktop)
- [Flutter Code Push Service](https://shorebird.dev/)
57 changes: 57 additions & 0 deletions Content/ko/044-20241209.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
author: sookim-1
description: UITextField 복사 붙여넣기, Cursor AI 사용시 느낀점, Medium 단축키, RN Code Push 종료
date: 2024-12-09 18:30
tags: iOS, Swift, Flutter, React Native, Blog, Cursor, UITextField
published: true
---
# 번호 : 044, 작성일자: 2024-12-09
## 2024.12.02 ~ 2024.12.08
### ⌨️ TextField 복사-붙여넣기 관련 정리

---

iOS 앱에서 사용자에게 문자열을 입력받기 위해 UITextField를 사용할 수 있습니다.

사용자는 UITextField에 직접 키보드로 입력하지 않고 붙여넣기를 할 수 있습니다.

이 때 동작하는 로직 순서에 대해서 알아봤습니다.


> 붙여넣기시 로직 순서
>
1. 붙여넣기를 진행한 경우 가장 먼저 UITextFieldDelegate의 메서드인 `shouldChangeCharactersIn`가 호출됩니다.
- 해당 부분에서 정규식검사를 통해 입력받지 않을 문자가 존재하는 경우 붙여넣기가 안되도록 처리할 수 있습니다.
2. editingChanged 에서 입력받은 텍스트를 전달받습니다.
- 입력받은 텍스트를 그대로 표시하거나 가공하여 표시할 수 있습니다.


> 붙여넣기 방지 방법
>
```swift
class CustomTextField: UITextField {

open override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
if action == #selector(UIResponderStandardEditActions.paste(_:)) {
return false
}

return super.canPerformAction(action, withSender: sender)
}

...
```

`UIResponderStandardEditActions` 프로토콜을 통해 각 종 액션을 방지할 수 있습니다.

### 🙋🏻‍♂️ 기타 사항

---

1. Cursor AI로 iOS프로젝트를 Flutter프로젝트로 변환하거나 특정 아키텍처패턴으로 리팩토링 요구등을 시도해보았는데 일단 느낀점은 UIKit프레임워크보다는 SwiftUI프레임워크 코드를 이해를 더 잘 하는 것 같고, 단순한 SnapKit, Then 라이브러리를 제거하고 각 기본방식으로 리팩토링등은 수월하지만 아키텍처패턴으로 리팩토링은 아직 사용할만한 수준은 아닌 것 같다.
2. Medium 블로그로 이전하면서 글 작성방법 단축키등을 살펴봤다.
3. ReactNative가 253월 이후로 Code Push가 종료된다는데 이제는 Flutter도 ShoreBird를 제공하니 각각 유료서비스를 사용해야하는 부분에서 Flutter가 좀 더 우위를 가져갈 것 같은 느낌이다..
- [RN Code Push 공식 종료글](https://learn.microsoft.com/ko-kr/appcenter/retirement)
- [RN Code Push 종료에 대한 글](https://www.linkedin.com/posts/cho-minkyu_discussion-visual-studio-app-center-retirement-activity-7249377764556881920-VcNr?utm_source=share&utm_medium=member_desktop)
- [Flutter Code Push 서비스](https://shorebird.dev/)

0 comments on commit 2681aec

Please sign in to comment.