Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6343977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:32:58+00:00 2026-05-24T20:32:58+00:00

I am new to Xcode and was wondering if anyone could help me with

  • 0

I am new to Xcode and was wondering if anyone could help me with this.

I need to make an application that is able to open a file and replace its contents.

E.g. (in psuedo code)

Replace(“String1”, “String2”, “~/Desktop/Sample.txt”)

Please let me know if I’m not clear enough.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:32:58+00:00Added an answer on May 24, 2026 at 8:32 pm

    You probably want this

    And regarding your question about how to read the text from a file to a NSString:

    NSError * error;
    NSString * stringFromFile;
    NSString * stringFilepath = @"loadfile.txt";
    stringFromFile = [[NSString alloc] initWithContentsOfFile:stringFilepath
                                              encoding:NSWindowsCP1250StringEncoding
                                                  error:&error];
    

    And for writing to a file:
    (using the same NSString from loading: stringFromFile)

    NSError * error;
    NSString * stringFilepath = @"savefile.txt";
    [stringFromFile writeToFile:stringFilepath atomically:YES encoding:NSWindowsCP1250StringEncoding error:error];
    

    Note that in this example i use an encoding for windows (this means it uses charcters \n\r at the end of each line). Check the documentation for other types of encoding.

    (See NSString documentation)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just update to new xcode and now the project file stopped being able
I am relatively new to Xcode and one thing that has bothered me is
I'm new to Xcode. This is probably a very simple question to you, but
Wondering if anyone has played around with GitHub's new support for SVN? Would really
I'm fairly new to xcode and iPhone development and I'm wondering if it's possible
The readme included with the new Xcode 3.2.1 this week says the following: Static
I was wondering if there is a way to programmatically create a new XCode
I have just installed new xcode with sdk 4.3b because I need 'airPlay' feature
In the new Xcode 4 Documentation Organizer, I can't find the sidebar outline that
Well you know they just released this new XCode 4 version thing...... I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.