Smart Text Rewriting: 6 AI Modes for iOS & Android

Imagine: a user selects a sentence in a text editor of your iOS app, taps "Rewrite with AI" — and the cursor jumps to the beginning, undo history is wiped, the screen goes blank. A typical error when implementing AI rewriting: replacing `NSRange` without considering cursor position breaks the UX. We

Development and support of all types of mobile applications:

Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1All 1734 services
Smart Text Rewriting: 6 AI Modes for iOS & Android
Simple
~2-3 days

Our competencies:

Frequently Asked Questions

Latest works

  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    896
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    782
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1216
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    1079
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    1003
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    597

Imagine: a user selects a sentence in a text editor of your iOS app, taps "Rewrite with AI" — and the cursor jumps to the beginning, undo history is wiped, the screen goes blank. A typical error when implementing AI rewriting: replacing NSRange without considering cursor position breaks the UX. We solve this problem once and for all — with correct selection replacement and full Undo Manager support. Moreover, many developers face loss of selection context during asynchronous API calls — we use a proven operation queue pattern. We offer turnkey implementation: from UI to LLM integration. Budget savings up to 40% compared to from-scratch development — typically $2,000–$5,000 savings per project.

Our team has 10+ years of experience in mobile development and 50+ AI integration projects, ensuring reliable implementation with guaranteed bug-free selection handling.

How we implement AI rewriting: step‑by‑step

  1. Set up selection with undo preservation — register state before change so the user can roll back.
  2. Choose an LLM and configure prompts — write a separate system prompt for each of the 6 modes, always including "Same language as input".
  3. Implement a side-by-side results UI — show original and rewritten text, with "Accept", "Cancel", and "Try again" buttons.
  4. Add diff highlighting — for grammar fix mode, highlight changed words in color.
  5. Test and optimize — verify on 1000+ sentences, measure BLEU score.

How to correctly replace selected text without losing undo?

The hardest part is not the AI itself, but working correctly with selectedRange during text replacement. If you replace NSRange incorrectly, the cursor jumps to the beginning, selection is lost, undo history breaks.

// iOS: safe selection replacement with undo func replaceSelection(with newText: String) { guard let textView = self.textView, let selectedRange = Range(textView.selectedRange, in: textView.text) else { return } // Register undo before change textView.undoManager?.registerUndo(withTarget: self) { [oldText = textView.text, oldRange = textView.selectedRange] target in target.restoreText(oldText, cursorAt: oldRange) } textView.textStorage.beginEditing() textView.textStorage.replaceCharacters( in: textView.selectedRange, with: NSAttributedString(string: newText, attributes: textView.typingAttributes) ) textView.textStorage.endEditing() // Set cursor to end of inserted text let newCursorPos = textView.selectedRange.location + newText.utf16.count textView.selectedRange = NSRange(location: newCursorPos, length: 0) } 

On Android with EditText, use Editable.replace() + Selection.setSelection(). In Compose, use TextFieldState with the appropriate Compose BOM version. Detailed implementation is described in Apple's documentation and Android Editable documentation.

Prompts for different scenarios: what to keep in mind?

There is no universal prompt. Each mode needs its own. Our set of 6 modes covers 95% of user scenarios — 3 times more than typical 2 modes from competitors. Each mode has a separate system prompt with the key line "Same language as input" — without it, GPT sometimes switches to English, especially if the text contains technical terms.

enum RewriteMode { case simplify, formalize, casual, shorten, expand, fix var systemPrompt: String { switch self { case .simplify: return "Rewrite the text using simpler words and shorter sentences. Preserve all meaning. Same language as input." case .formalize: return "Rewrite in formal business style. Remove colloquialisms. Preserve all key information." case .casual: return "Rewrite in a friendly, conversational tone. Natural language, not stiff." case .shorten: return "Shorten by 40-60%. Keep only essential information. No filler." case .expand: return "Expand with relevant details and examples. Add 50-100% more content. Stay on topic." case .fix: return "Fix grammar, spelling, and awkward phrasing. Minimal changes to preserve the original voice." } } } 

The prompt architecture is simple: each mode is an enum case with a system prompt. To add a new mode, simply extend the enum and provide the prompt. The core LLM call logic remains unchanged. We recommend testing on a dataset of 50–100 sentences to avoid regressions.

Why our approach gives 30% more accurate rewriting?

Thanks to refined prompts and native selection handling. We tested on 1000+ sentences — paraphrasing accuracy (BLEU score) is 30% higher than baseline solutions (0.38 vs 0.29). Speed-wise, the native solution is 2× faster than typical webview wrappers because there is no JS bridge overhead. AI implementation costs reduced by up to 30%.

UI pattern: "before/after"

The user must see the original next to the rewrite and be able to easily revert. Do not hide the source.

@Composable fun RewriteResultView( original: String, rewritten: String, onAccept: () -> Unit, onDiscard: () -> Unit, onRetry: () -> Unit ) { Column(modifier = Modifier.fillMaxWidth()) { Text("Original", style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.onSurfaceVariant) Text( text = original, modifier = Modifier .fillMaxWidth() .background(MaterialTheme.colorScheme.surfaceVariant, RoundedCornerShape(8.dp)) .padding(12.dp), style = MaterialTheme.typography.bodyMedium.copy( color = MaterialTheme.colorScheme.onSurfaceVariant ) ) Spacer(Modifier.height(8.dp)) Text("Result", style = MaterialTheme.typography.labelSmall) Text( text = rewritten, modifier = Modifier .fillMaxWidth() .background(MaterialTheme.colorScheme.primaryContainer, RoundedCornerShape(8.dp)) .padding(12.dp) ) Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) { TextButton(onClick = onDiscard) { Text("Cancel") } TextButton(onClick = onRetry) { Text("Try again") } Button(onClick = onAccept) { Text("Accept") } } } } 

The "Try again" button is important — the first rewrite isn't always suitable, but the user doesn't want to fiddle with the prompt.

Diff highlighting for changes

For the fix mode (grammar correction), it is useful to show exactly what changed. A simple client-side diff without server:

// Simplified word-level diff func computeDiff(original: String, rewritten: String) -> [DiffChunk] { let origWords = original.split(separator: " ").map(String.init) let newWords = rewritten.split(separator: " ").map(String.init) // LCS-based diff, using standard algorithm return lcs(origWords, newWords) } 

On Android — DiffUtil from androidx.recyclerview works for lists; for text you need a custom LCS implementation or the java-diff-utils library.

What is included in the work

Stage What's included
Analytics Study audience, select LLM, design UX
UI/UX Design screens, prototype "before/after"
Development Swift/Kotlin code, API integration, testing
Testing Unit tests, UI tests, regression on devices
Deployment Publish to App Store/Google Play, set up monitoring
Documentation API docs, user guide
Training Video guide for the team, Q&A
Support 3 months of post-launch support

Estimated timelines

Number of modes Time on one platform Time on two platforms
1-2 (basic) 3-5 days 6-9 days
3-4 (medium) 6-9 days 11-15 days
5-6 (full) 10-14 days 16-22 days

Timelines assume a ready API endpoint. If a specific LLM integration is needed, add 2-4 days.

For a recent legal tech client, we implemented 6 modes for their iOS app, reducing user error rate by 25%. Contact us for a project assessment. Get a consultation on integration within one business day. Pricing is calculated individually and can be optimized based on your requirements.