15 Expert Prompts for Swift and iOS: Mastering SwiftUI, UIKit, Core Data, and Combine

Introduction

As an iOS developer in 2026, your ability to craft precise prompts for AI assistants can dramatically accelerate your workflow. Whether you're debugging a SwiftUI layout, optimizing a Core Data fetch, or architecting a Combine pipeline, the right prompt can save hours of trial and error. This article compiles 15 expert-level prompts organized by category—basic, advanced, and expert—designed to help you solve real-world iOS problems with Swift, SwiftUI, UIKit, Core Data, and Combine. Each prompt includes a clear task, the exact prompt text, and a concrete example result. These are battle-tested in my own projects and refined through community feedback on forums like Swift Forums and Apple Developer Forums. Let's dive in.

Basic Prompts

1. Generating a SwiftUI List with NavigationLink

Task: Create a reusable SwiftUI list that displays an array of models and navigates to a detail view.

Prompt:

Generate a SwiftUI view that displays a list of items from a `Book` model (title, author, year). Each row shows the book title and author, and tapping navigates to a `BookDetailView` that receives the full `Book` object. Use `NavigationStack` and `NavigationLink`. Include a preview.

Example Result:

import SwiftUI

struct Book: Identifiable {
    let id = UUID()
    let title: String
    let author: String
    let year: Int
}

struct BookListView: View {
    let books = [
        Book(title: "1984", author: "George Orwell", year: 1949),
        Book(title: "Brave New World", author: "Aldous Huxley", year: 1932)
    ]

    var body: some View {
        NavigationStack {
            List(books) { book in
                NavigationLink(destination: BookDetailView(book: book)) {
                    VStack(alignment: .leading) {
                        Text(book.title).font(.headline)
                        Text(book.author).font(.subheadline).foregroundColor(.secondary)
                    }
                }
            }
            .navigationTitle("Books")
        }
    }
}

struct BookDetailView: View {
    let book: Book
    var body: some View {
        VStack(spacing: 16) {
            Text(book.title).font(.largeTitle)
            Text(book.author).font(.title2)
            Text("Published: \(book.year)")
        }
        .padding()
        .navigationTitle(book.title)
    }
}

#Preview {
    BookListView()
}

2. Creating a UIKit TableView with Custom Cell

Task: Build a simple UITableView with a custom UITableViewCell using programmatic Auto Layout.

Prompt:

Write a `UIViewController` that manages a `UITableView` with a custom cell class `ContactCell`. The cell should display a contact name and phone number using two `UILabel`s. Configure the cell in `tableView(_:cellForRowAt:)`. Use `NSLayoutConstraint` for layout. Provide a sample data array of dictionaries.

Example Result:

import UIKit

class ContactCell: UITableViewCell {
    static let reuseIdentifier = "ContactCell"

    let nameLabel = UILabel()
    let phoneLabel = UILabel()

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupViews()
    }

    required init?(coder: NSCoder) { fatalError() }

    private func setupViews() {
        nameLabel.translatesAutoresizingMaskIntoConstraints = false
        phoneLabel.translatesAutoresizingMaskIntoConstraints = false
        contentView.addSubview(nameLabel)
        contentView.addSubview(phoneLabel)

        NSLayoutConstraint.activate([
            nameLabel.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 8),
            nameLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 16),
            nameLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -16),
            phoneLabel.topAnchor.constraint(equalTo: nameLabel.bottomAnchor, constant: 4),
            phoneLabel.leadingAnchor.constraint(equalTo: nameLabel.leadingAnchor),
            phoneLabel.trailingAnchor.constraint(equalTo: nameLabel.trailingAnchor),
            phoneLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -8)
        ])
    }
}

class ContactListViewController: UIViewController, UITableViewDataSource {
    let tableView = UITableView()
    let contacts: [[String: String]] = [
        ["name": "Alice", "phone": "555-0100"],
        ["name": "Bob", "phone": "555-0101"]
    ]

    override func viewDidLoad() {
        super.viewDidLoad()
        view.addSubview(tableView)
        tableView.frame = view.bounds
        tableView.dataSource = self
        tableView.register(ContactCell.self, forCellReuseIdentifier: ContactCell.reuseIdentifier)
    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        contacts.count
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: ContactCell.reuseIdentifier, for: indexPath) as! ContactCell
        let contact = contacts[indexPath.row]
        cell.nameLabel.text = contact["name"]
        cell.phoneLabel.text = contact["phone"]
        return cell
    }
}

3. Setting Up Core Data Stack

Task: Initialize a minimal Core Data stack using NSPersistentContainer.

Prompt:

Provide a `CoreDataManager` singleton that sets up a Core Data stack with a container named "Model". Include a `viewContext` property and a `saveContext()` method that handles errors gracefully. Assume the .xcdatamodeld file is already created.

Example Result:

import CoreData

class CoreDataManager {
    static let shared = CoreDataManager()

    lazy var persistentContainer: NSPersistentContainer = {
        let container = NSPersistentContainer(name: "Model")
        container.loadPersistentStores { _, error in
            if let error = error as NSError? {
                fatalError("Unresolved error \(error), \(error.userInfo)")
            }
        }
        return container
    }()

    var viewContext: NSManagedObjectContext {
        persistentContainer.viewContext
    }

    func saveContext() {
        let context = viewContext
        if context.hasChanges {
            do {
                try context.save()
            } catch {
                let nserror = error as NSError
                print("Failed to save context: \(nserror), \(nserror.userInfo)")
            }
        }
    }
}

4. Simple Combine Publisher

Task: Create a publisher that emits a string after a delay.

Prompt:

Write a Combine publisher that emits the string "Hello, Combine!" after a 2-second delay. Use `Future` and demonstrate subscribing with `sink` and storing the cancellable.

Example Result:

import Combine

var cancellables = Set<AnyCancellable>()

let futurePublisher = Future<String, Never> { promise in
    DispatchQueue.global().asyncAfter(deadline: .now() + 2) {
        promise(.success("Hello, Combine!"))
    }
}

futurePublisher
    .receive(on: DispatchQueue.main)
    .sink { value in
        print(value) // Prints "Hello, Combine!" after 2 seconds
    }
    .store(in: &cancellables)

Advanced Prompts

5. SwiftUI Form with Validation

Task: Build a registration form with email and password fields, including inline validation.

Prompt:

Create a SwiftUI view `RegistrationForm` with `@State` properties for email and password. Add validation: email must contain '@', password must be at least 8 characters. Show error messages below each field only after the user has edited it. Disable the submit button if validation fails. Include a `VStack` and `Form`.

Example Result:

import SwiftUI

struct RegistrationForm: View {
    @State private var email = ""
    @State private var password = ""
    @State private var didEditEmail = false
    @State private var didEditPassword = false

    var isEmailValid: Bool { email.contains("@") }
    var isPasswordValid: Bool { password.count >= 8 }
    var isFormValid: Bool { isEmailValid && isPasswordValid }

    var body: some View {
        Form {
            Section("Credentials") {
                TextField("Email", text: $email)
                    .onChange(of: email) { _ in didEditEmail = true }
                    .textContentType(.emailAddress)
                    .autocapitalization(.none)
                    .overlay(
                        Group {
                            if didEditEmail && !isEmailValid {
                                Text("Enter a valid email")
                                    .foregroundColor(.red)
                                    .font(.caption)
                            }
                        },
                        alignment: .bottomLeading
                    )

                SecureField("Password", text: $password)
                    .onChange(of: password) { _ in didEditPassword = true }
                    .overlay(
                        Group {
                            if didEditPassword && !isPasswordValid {
                                Text("At least 8 characters")
                                    .foregroundColor(.red)
                                    .font(.caption)
                            }
                        },
                        alignment: .bottomLeading
                    )
            }

            Section {
                Button("Submit") {
                    print("Submitted: \(email), \(password)")
                }
                .disabled(!isFormValid)
            }
        }
        .navigationTitle("Register")
    }
}

6. UIKit CollectionView with Compositional Layout

Task: Implement a UICollectionView using UICollectionViewCompositionalLayout with a list and a grid section.

Prompt:

Write a `UIViewController` that uses a `UICollectionView` with a `UICollectionViewCompositionalLayout`. The layout should have two sections: section 0 uses a list (`.list`), section 1 uses a 3-column grid (`.fractionalWidth(1/3)`). Use a single cell class `TextCell` with a `UILabel`. Provide sample data as an array of strings.

Example Result:

import UIKit

class TextCell: UICollectionViewCell {
    static let reuseIdentifier = "TextCell"
    let label = UILabel()

    override init(frame: CGRect) {
        super.init(frame: frame)
        contentView.addSubview(label)
        label.translatesAutoresizingMaskIntoConstraints = false
        NSLayoutConstraint.activate([
            label.centerXAnchor.constraint(equalTo: contentView.centerXAnchor),
            label.centerYAnchor.constraint(equalTo: contentView.centerYAnchor)
        ])
        contentView.backgroundColor = .systemGray6
        contentView.layer.cornerRadius = 8
    }
    required init?(coder: NSCoder) { fatalError() }
}

class CompositionalViewController: UIViewController, UICollectionViewDataSource {
    let collectionView = UICollectionView(frame: .zero, collectionViewLayout: createLayout())
    let data = [
        ["Item 1", "Item 2", "Item 3"],
        ["Grid A", "Grid B", "Grid C", "Grid D", "Grid E", "Grid F"]
    ]

    static func createLayout() -> UICollectionViewCompositionalLayout {
        let config = UICollectionLayoutListConfiguration(appearance: .plain)
        let listSection = NSCollectionLayoutSection.list(using: config, layoutEnvironment: .init(traitCollection: .current, container: .init(), size: .zero))

        let gridItem = NSCollectionLayoutItem(layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1/3), heightDimension: .fractionalHeight(1.0)))
        let gridGroup = NSCollectionLayoutGroup.horizontal(layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .absolute(100)), subitems: [gridItem])
        let gridSection = NSCollectionLayoutSection(group: gridGroup)

        let layout = UICollectionViewCompositionalLayout { sectionIndex, _ in
            sectionIndex == 0 ? listSection : gridSection
        }
        return layout
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        view.addSubview(collectionView)
        collectionView.frame = view.bounds
        collectionView.dataSource = self
        collectionView.register(TextCell.self, forCellWithReuseIdentifier: TextCell.reuseIdentifier)
    }

    func numberOfSections(in collectionView: UICollectionView) -> Int { data.count }
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { data[section].count }
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: TextCell.reuseIdentifier, for: indexPath) as! TextCell
        cell.label.text = data[indexPath.section][indexPath.row]
        return cell
    }
}

7. Core Data Fetch with Predicates and Sort

Task: Fetch Person entities with a predicate and sort descriptor.

Prompt:

Given a Core Data entity `Person` with attributes `name` (String) and `age` (Int16), write a fetch request that returns all persons older than 25, sorted by name ascending. Use `NSFetchRequest` and `NSPredicate`. Return an array of `Person` objects.

Example Result:

import CoreData

func fetchAdults() -> [Person] {
    let context = CoreDataManager.shared.viewContext
    let fetchRequest: NSFetchRequest<Person> = Person.fetchRequest()
    fetchRequest.predicate = NSPredicate(format: "age > %d", 25)
    fetchRequest.sortDescriptors = [NSSortDescriptor(key: "name", ascending: true)]

    do {
        return try context.fetch(fetchRequest)
    } catch {
        print("Fetch failed: \(error)")
        return []
    }
}

8. Combine Networking with URLSession

Task: Fetch JSON from an API using Combine and decode it.

Prompt:

Write a function `fetchUsers()` that returns `AnyPublisher<[User], Error>`. Use `URLSession.shared.dataTaskPublisher` and `decode` to parse JSON. Assume `User` conforms to `Codable` with `id` and `name`. Use a fake API endpoint like "https://jsonplaceholder.typicode.com/users".

Example Result:

import Combine
import Foundation

struct User: Codable, Identifiable {
    let id: Int
    let name: String
}

func fetchUsers() -> AnyPublisher<[User], Error> {
    let url = URL(string: "https://jsonplaceholder.typicode.com/users")!
    return URLSession.shared.dataTaskPublisher(for: url)
        .map(\.data)
        .decode(type: [User].self, decoder: JSONDecoder())
        .receive(on: DispatchQueue.main)
        .eraseToAnyPublisher()
}

// Usage
var cancellables = Set<AnyCancellable>()
fetchUsers()
    .sink(receiveCompletion: { completion in
        if case .failure(let error) = completion {
            print("Error: \(error)")
        }
    }, receiveValue: { users in
        print("Fetched \(users.count) users")
    })
    .store(in: &cancellables)

Expert Prompts

9. SwiftUI Custom Animation with Springs

Task: Create a custom spring animation for a scaling effect.

Prompt:

Write a SwiftUI view that toggles a scale effect using `.spring(response:dampingFraction:)` with custom parameters: response 0.55, dampingFraction 0.625. Add a button to trigger the animation. Use `@State` for scale.

Example Result:

import SwiftUI

struct SpringAnimationView: View {
    @State private var scale: CGFloat = 1.0

    var body: some View {
        VStack(spacing: 40) {
            Circle()
                .fill(Color.blue)
                .frame(width: 100, height: 100)
                .scaleEffect(scale)
                .animation(.spring(response: 0.55, dampingFraction: 0.625), value: scale)

            Button("Animate") {
                scale = scale == 1.0 ? 1.5 : 1.0
            }
        }
    }
}

10. UIKit Custom Transition Animation

Task: Implement a custom UIViewControllerAnimatedTransitioning for a modal presentation.

Prompt:

Create a custom transition animator that slides the presented view controller from the bottom. Implement `transitionDuration(using:)` returning 0.5 seconds, and `animateTransition(using:)` that moves the presented view from `CGRect(x:0, y:view.bounds.height, ...)` to its final frame. Provide a `UIPercentDrivenInteractiveTransition` class for interactive dismissal.

Example Result:

import UIKit

class SlideUpAnimator: NSObject, UIViewControllerAnimatedTransitioning {
    func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
        0.5
    }

    func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
        guard let toView = transitionContext.view(forKey: .to) else { return }
        let container = transitionContext.containerView
        toView.frame = CGRect(x: 0, y: container.bounds.height, width: container.bounds.width, height: container.bounds.height)
        container.addSubview(toView)

        UIView.animate(withDuration: transitionDuration(using: transitionContext), animations: {
            toView.frame.origin.y = 0
        }) { finished in
            transitionContext.completeTransition(finished)
        }
    }
}

class InteractiveDismissTransition: UIPercentDrivenInteractiveTransition {
    var interactionInProgress = false
    private var shouldCompleteTransition = false
    private weak var viewController: UIViewController?

    func wireTo(viewController: UIViewController) {
        self.viewController = viewController
        let gesture = UIPanGestureRecognizer(target: self, action: #selector(handlePan(_:)))
        viewController.view.addGestureRecognizer(gesture)
    }

    @objc private func handlePan(_ gesture: UIPanGestureRecognizer) {
        guard let view = gesture.view else { return }
        let translation = gesture.translation(in: view)
        let progress = min(max(translation.y / view.bounds.height, 0), 1)

        switch gesture.state {
        case .began:
            interactionInProgress = true
            viewController?.dismiss(animated: true)
        case .changed:
            shouldCompleteTransition = progress > 0.5
            update(progress)
        case .cancelled:
            interactionInProgress = false
            cancel()
        case .ended:
            interactionInProgress = false
            shouldCompleteTransition ? finish() : cancel()
        default:
            break
        }
    }
}

11. Core Data Batch Operations

Task: Perform a batch update and batch delete using NSBatchUpdateRequest and NSBatchDeleteRequest.

Prompt:

Write a function `batchUpdateSalaries() ` that increases the `salary` attribute of all `Employee` entities by 10% using `NSBatchUpdateRequest`. Also write a function `deleteOldRecords(before: Date)` that deletes all `Event` entities with `date` older than the given date using `NSBatchDeleteRequest`. Both should return a result and merge changes.

Example Result:

import CoreData

func batchUpdateSalaries() {
    let context = CoreDataManager.shared.viewContext
    let batchUpdate = NSBatchUpdateRequest(entityName: "Employee")
    batchUpdate.propertiesToUpdate = ["salary": NSExpression(forFunction: "multiply:by:", arguments: [NSExpression(forKeyPath: "salary"), NSExpression(forConstantValue: 1.1)])]
    batchUpdate.resultType = .updatedObjectsCountResultType

    do {
        let result = try context.execute(batchUpdate) as? NSBatchUpdateResult
        print("Updated \(result?.result ?? 0) employees")
        context.refreshAllObjects()
    } catch {
        print("Batch update failed: \(error)")
    }
}

func deleteOldRecords(before date: Date) {
    let context = CoreDataManager.shared.viewContext
    let fetchRequest: NSFetchRequest<NSFetchRequestResult> = Event.fetchRequest()
    fetchRequest.predicate = NSPredicate(format: "date < %@", date as NSDate)
    let batchDelete = NSBatchDeleteRequest(fetchRequest: fetchRequest)
    batchDelete.resultType = .resultTypeCount

    do {
        let result = try context.execute(batchDelete) as? NSBatchDeleteResult
        print("Deleted \(result?.result ?? 0) events")
        context.refreshAllObjects()
    } catch {
        print("Batch delete failed: \(error)")
    }
}

12. Combine with Multiple Publishers and Zip

Task: Combine three network requests using Zip and process results.

Prompt:

Write a function that fetches user profile, posts, and comments simultaneously using three different API endpoints. Use `Publishers.Zip3` to combine them into a single tuple. Decode each into `Profile`, `[Post]`, `[Comment]`. Return `AnyPublisher<(Profile, [Post], [Comment]), Error>`. Use JSONPlaceholder endpoints.

Example Result:

import Combine
import Foundation

struct Profile: Codable { let id: Int; let name: String }
struct Post: Codable, Identifiable { let id: Int; let title: String }
struct Comment: Codable, Identifiable { let id: Int; let body: String }

func fetchProfile() -> AnyPublisher<Profile, Error> {
    let url = URL(string: "https://jsonplaceholder.typicode.com/users/1")!
    return URLSession.shared.dataTaskPublisher(for: url).map(\.data).decode(type: Profile.self, decoder: JSONDecoder()).eraseToAnyPublisher()
}

func fetchPosts() -> AnyPublisher<[Post], Error> {
    let url = URL(string: "https://jsonplaceholder.typicode.com/posts?userId=1")!
    return URLSession.shared.dataTaskPublisher(for: url).map(\.data).decode(type: [Post].self, decoder: JSONDecoder()).eraseToAnyPublisher()
}

func fetchComments() -> AnyPublisher<[Comment], Error> {
    let url = URL(string: "https://jsonplaceholder.typicode.com/comments?postId=1")!
    return URLSession.shared.dataTaskPublisher(for: url).map(\.data).decode(type: [Comment].self, decoder: JSONDecoder()).eraseToAnyPublisher()
}

func fetchAllData() -> AnyPublisher<(Profile, [Post], [Comment]), Error> {
    Publishers.Zip3(fetchProfile(), fetchPosts(), fetchComments())
        .eraseToAnyPublisher()
}

13. SwiftUI and Core Data Integration with @FetchRequest

Task: Use @FetchRequest in a SwiftUI view to display Core Data entities with a predicate.

Prompt:

Create a SwiftUI view `TaskListView` that uses `@FetchRequest` to fetch `Task` entities where `isCompleted == false`. Sort by `dueDate` ascending. Provide a `Button` to toggle completion and call `saveContext()`. Assume `Task` entity has attributes `title`, `dueDate`, `isCompleted`.

Example Result:

import SwiftUI
import CoreData

struct TaskListView: View {
    @Environment(\.managedObjectContext) private var viewContext
    @FetchRequest(
        sortDescriptors: [NSSortDescriptor(keyPath: \Task.dueDate, ascending: true)],
        predicate: NSPredicate(format: "isCompleted == NO")
    ) private var tasks: FetchedResults<Task>

    var body: some View {
        List {
            ForEach(tasks) { task in
                HStack {
                    VStack(alignment: .leading) {
                        Text(task.title ?? "")
                            .font(.headline)
                        Text(task.dueDate ?? Date(), style: .date)
                            .font(.caption)
                    }
                    Spacer()
                    Button("Done") {
                        task.isCompleted = true
                        try? viewContext.save()
                    }
                }
            }
        }
        .navigationTitle("Tasks")
    }
}

14. UIKit with Combine: Reactive Text Field

Task: Bind a UITextField text changes to a Combine publisher.

Prompt:

Write a `UIViewController` with a `UITextField` and a `UILabel`. Use Combine's `NotificationCenter` publisher for `UITextField.textDidChangeNotification` to update the label in real-time as the user types. Store cancellables in a `Set<AnyCancellable>`.

Example Result:

import UIKit
import Combine

class ReactiveTextFieldViewController: UIViewController {
    let textField = UITextField()
    let label = UILabel()
    var cancellables = Set<AnyCancellable>()

    override func viewDidLoad() {
        super.viewDidLoad()
        view.addSubview(textField)
        view.addSubview(label)
        textField.borderStyle = .roundedRect
        textField.frame = CGRect(x: 20, y: 100, width: 280, height: 40)
        label.frame = CGRect(x: 20, y: 160, width: 280, height: 40)

        NotificationCenter.default.publisher(for: UITextField.textDidChangeNotification, object: textField)
            .compactMap { ($0.object as? UITextField)?.text }
            .map { "You typed: \($0)" }
            .assign(to: \.text, on: label)
            .store(in: &cancellables)
    }
}

15. Advanced Core Data with NSFetchedResultsController

Task: Use NSFetchedResultsController with a UITableView for automatic updates.

Prompt:

Write a `UITableViewController` subclass that uses `NSFetchedResultsController` to display `Message` entities sorted by `timestamp` descending. Implement the delegate methods to automatically insert, delete, and move rows. Assume `Message` has attributes `text` and `timestamp`.

Example Result:

import UIKit
import CoreData

class MessageListViewController: UITableViewController, NSFetchedResultsControllerDelegate {
    lazy var fetchedResultsController: NSFetchedResultsController<Message> = {
        let fetchRequest: NSFetchRequest<Message> = Message.fetchRequest()
        fetchRequest.sortDescriptors = [NSSortDescriptor(key: "timestamp", ascending: false)]
        let controller = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: CoreDataManager.shared.viewContext, sectionNameKeyPath: nil, cacheName: nil)
        controller.delegate = self
        try? controller.performFetch()
        return controller
    }()

    override func viewDidLoad() {
        super.viewDidLoad()
        tableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell")
    }

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        fetchedResultsController.sections?[section].numberOfObjects ?? 0
    }

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
        let message = fetchedResultsController.object(at: indexPath)
        cell.textLabel?.text = message.text
        return cell
    }

    // NSFetchedResultsControllerDelegate methods
    func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
        tableView.beginUpdates()
    }

    func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
        switch type {
        case .insert: if let newIndexPath = newIndexPath { tableView.insertRows(at: [newIndexPath], with: .automatic) }
        case .delete: if let indexPath = indexPath { tableView.deleteRows(at: [indexPath], with: .automatic) }
        case .update: if let indexPath = indexPath { tableView.reloadRows(at: [indexPath], with: .automatic) }
        case .move: if let indexPath = indexPath, let newIndexPath = newIndexPath { tableView.moveRow(at: indexPath, to: newIndexPath) }
        @unknown default: break
        }
    }

    func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
        tableView.endUpdates()
    }
}

Conclusion

These 15 prompts cover a broad spectrum of iOS development—from basic SwiftUI lists and UIKit table views to advanced Core Data batch operations and Combine networking. By using these prompts as templates, you can accelerate your development and focus on unique business logic. Remember, the key to effective prompting is specificity: always include model names, attribute types, and expected behaviors. As you integrate these patterns into your workflow, you'll find that AI-assisted coding becomes a natural extension of your expertise. Experiment with variations, combine prompts, and adapt them to your project's architecture. The future of iOS development is collaborative—between you and your AI pair programmer.

For more advanced patterns and community-driven prompt libraries, visit Swift Forums and Apple Developer Documentation.

← All posts

Comments