Skip to main content

Overview

Chat with Code is Parsaa’s core feature that allows you to interact with your Swift code using natural language. Simply select any code in Xcode and get intelligent explanations, suggestions, and improvements from our AI assistant.
Real-time Assistance: Get instant feedback and suggestions as you code, without leaving your development environment.

How It Works

Basic Usage

1

Select Code

In Xcode, select any Swift code you want to analyze or improve:
func calculateTotal(items: [Item]) -> Double {
    var total = 0.0
    for item in items {
        total += item.price
    }
    return total
}
2

Open Chat

Right-click on the selected code and choose “Chat with Parsaa” from the context menu, or use the keyboard shortcut ⌘⇧P.
3

Ask Questions

Type your question in natural language:
  • “How can I optimize this function?”
  • “What are potential issues with this code?”
  • “Can you explain what this code does?”
  • “How can I make this more Swift-like?”
4

Get AI Response

Parsaa will provide:
  • Detailed explanations
  • Code improvements
  • Performance optimizations
  • Best practice suggestions
  • Alternative implementations

Example Interactions

Code Explanation

Your Question: “What does this code do?” Selected Code:
let numbers = [1, 2, 3, 4, 5]
let doubled = numbers.map { $0 * 2 }
let sum = doubled.reduce(0, +)
Parsaa’s Response:
This code performs a functional programming operation on an array of numbers:
  1. numbers: Creates an array containing integers 1 through 5
  2. map { $0 * 2 }: Transforms each number by multiplying by 2, resulting in [2, 4, 6, 8, 10]
  3. reduce(0, +): Sums all the doubled values, giving you 30
This is a common pattern for applying a transformation and then aggregating the results.

Code Optimization

Your Question: “How can I optimize this function?” Selected Code:
func findUser(by id: String) -> User? {
    for user in users {
        if user.id == id {
            return user
        }
    }
    return nil
}
Parsaa’s Response:
Here are several ways to optimize this function:
// Option 1: Use first(where:) - most Swift-like
func findUser(by id: String) -> User? {
    return users.first { $0.id == id }
}

// Option 2: Use a Set for O(1) lookup (if users don't change often)
private let userSet: Set<User>
func findUser(by id: String) -> User? {
    return userSet.first { $0.id == id }
}

// Option 3: Use a Dictionary for direct lookup
private let userDict: [String: User]
func findUser(by id: String) -> User? {
    return userDict[id]
}

Error Analysis

Your Question: “What’s wrong with this code?” Selected Code:
var numbers: [Int] = []
numbers.append(1)
numbers.append(2)
let result = numbers[5] // This will crash!
Parsaa’s Response:
⚠️ Critical Issue: Array index out of bounds Problem: You’re trying to access index 5 in an array that only has 2 elements (indices 0 and 1). Solutions:
  1. Safe access: Use first or last properties
  2. Bounds checking: Check array count before accessing
  3. Optional chaining: Use safe subscripting
// Safe approaches:
let result = numbers.indices.contains(5) ? numbers[5] : nil
let result = numbers.dropFirst(5).first
let result = numbers.count > 5 ? numbers[5] : nil

Advanced Features

Context-Aware Suggestions

Parsaa understands your project context and provides relevant suggestions:
When working with UIKit, SwiftUI, or other frameworks, Parsaa provides framework-specific suggestions:
// Parsaa knows you're using SwiftUI
@State private var isPresented = false

// Suggests: "Consider using @StateObject for ObservableObject properties"
Parsaa learns from your codebase and suggests patterns consistent with your project:
// If your project uses MVVM, Parsaa will suggest ViewModel patterns
class UserViewModel: ObservableObject {
    @Published var users: [User] = []
}
Get suggestions for improving performance based on your specific use case:
// Parsaa might suggest:
// "Consider using lazy loading for large datasets"
// "This could benefit from background processing"

Code Generation

Ask Parsaa to generate code based on your requirements: Example: “Create a network manager with error handling” Parsaa’s Response:
class NetworkManager {
    static let shared = NetworkManager()
    private let session = URLSession.shared
    
    func fetch<T: Codable>(_ type: T.Type, from url: URL) async throws -> T {
        do {
            let (data, response) = try await session.data(from: url)
            
            guard let httpResponse = response as? HTTPURLResponse,
                  200...299 ~= httpResponse.statusCode else {
                throw NetworkError.invalidResponse
            }
            
            return try JSONDecoder().decode(type, from: data)
        } catch {
            throw NetworkError.requestFailed(error)
        }
    }
}

enum NetworkError: Error {
    case invalidResponse
    case requestFailed(Error)
}

Best Practices

Effective Questioning

  • Be Specific
  • Provide Context
  • Ask Follow-ups
Good: “How can I make this function more performant for large arrays?”Avoid: “How can I improve this?”

Privacy Considerations

Code Privacy: By default, Parsaa processes your code locally for maximum privacy. Cloud processing is optional and clearly indicated.
  • All code analysis happens on your machine
  • No code is sent to external servers
  • Maximum privacy and security
  • Optional for enhanced capabilities
  • Code is encrypted before transmission
  • You can disable cloud features anytime

Keyboard Shortcuts

ShortcutAction
⌘⇧POpen Chat with Code
⌘⇧EExplain selected code
⌘⇧OOptimize selected code
⌘⇧RRefactor selected code
⌘⇧TGenerate tests for selected code

Troubleshooting

Common Issues

Solutions:
  1. Check your internet connection (for cloud features)
  2. Restart the Parsaa extension
  3. Verify your account is active
  4. Check Xcode console for error messages
Solutions:
  1. Try using local processing mode
  2. Reduce the amount of selected code
  3. Check system resources
  4. Update to latest Parsaa version
Solutions:
  1. Provide more context in your questions
  2. Select more relevant code
  3. Try rephrasing your question
  4. Use the feedback feature to improve suggestions

Tips for Better Results

Select Relevant Code

Choose code that’s directly related to your question for more accurate responses.

Provide Context

Mention your project type, framework, or specific requirements in your questions.

Ask Specific Questions

Be specific about what you want to know or improve.

Use Follow-up Questions

Ask follow-up questions to dive deeper into suggestions.
Pro Tip: The more context you provide, the better Parsaa’s suggestions will be. Include information about your project’s architecture, performance requirements, and coding standards.