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 6778037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:13:08+00:00 2026-05-26T16:13:08+00:00

Am getting errors in this piece of code; I have placed the error messages

  • 0

Am getting errors in this piece of code; I have placed the error messages in the comments. Can’t figure it out.

Thanks in advance.

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{

    @autoreleasepool {

        NSMutableString *str = [[NSMutableString alloc]init];
        for (int i = 0; i < 10; i++) {
        [str appendString:@"Aaron is cool!\n"];
        }

        // Declare a pointer to an NSError object, but don't instantiate it.
        // The NSError instance will only be created if there is, in fact, an error.
        NSError *error = nil;

        // Pass the error pointer by reference to the NSString method
        BOOL success =[str writeToFile:@"/tmp/cool.txt"; // Expected "]"
          atomically:YES // Bad receiver type 'int'
            encoding:NSUTF8StringEncoding 
               error:&error];

        // Test the returned BOOL, and query the NSError if the write failed
        if (success) {
        NSLog(@"done writing /tmp/cool.txt");
        } else {
        NSLog(@"writing /tmp/cool/txt failed:@", error localizedDescription); //    Expected ')'
        }

    }
    return 0;
}
  • 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-26T16:13:09+00:00Added an answer on May 26, 2026 at 4:13 pm

    try this:

    @autoreleasepool {
        NSMutableString *str = [[[NSMutableString alloc]init] autorelease];
        for (int i = 0; i < 10; i++) {
            [str appendString:@"Aaron is cool!\n"];
        }
        NSError *error = nil;
        BOOL success =[str writeToFile:@"/tmp/cool.txt"
                            atomically:YES
                              encoding:NSUTF8StringEncoding 
                                 error:&error];
        if (success) {
            NSLog(@"done writing /tmp/cool.txt");
        } else {
            NSLog(@"writing /tmp/cool/txt failed: %@", [error localizedDescription]); 
        }
    
    }
    return 0;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following piece of code. This is written for getting the list
I have this piece of code which works 90% of the time: $user_details=$fb->api_client->users_getInfo($fb_user, array('last_name','first_name','proxied_email'));
I have this piece of code: <?php $pattern = /<span\b[^>]*>(.*?)</; $html = file_get_contents(http://www.bicicletapublica.com.ar/mapa.aspx); $results
I have a piece of .NET code that is erroring out when it makes
In a piece of code I've written, I have this line: AllSprites = (ArrayList<ClSprite>)
I am having issues getting this piece of code to compile. I am compiling
I have this simple piece of code that uses boost::bind: #include <boost/bind.hpp> #include <utility>
I have this small piece of code I got from a friend, but i
every body. I am getting this error: You have an error in your SQL
I'm getting this error and I don't know the reason. I have the following

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.