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

  • Home
  • SEARCH
  • 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 8118559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:31:34+00:00 2026-06-06T04:31:34+00:00

i have seen this block of code in this Stackoverflow as a answer of

  • 0

i have seen this block of code in this Stackoverflow as a answer of some ones question,i tried to impliment that in my code but i am not getting what kind of function is this and how can i call that

NSString * ReplaceFirstNewLine(NSString * original)
{
    NSMutableString * newString = [NSMutableString stringWithString:original];

    NSRange foundRange = [original rangeOfString:@"\n"];
    if (foundRange.location != NSNotFound)
    {
        [newString replaceCharactersInRange:foundRange
                                 withString:@""];
    }
    NSLog(@"%@",newString);
    return [[newString retain] autorelease];
}

i have tried to call this like [self ReplaceFirstNewLine(@"\nstirng\nstring")];
but its giving syntax error,can any one help me out

  • 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-06-06T04:31:35+00:00Added an answer on June 6, 2026 at 4:31 am

    First of all, it’s not a method, it’s a C function, similar to NSLog, so use it as such:

    NSString *results = ReplaceFirstNewLine(@"\nstirng\nstring");
    NSLog(@"%@", results);
    

    C-style-functions have advantages and disadvantages, and I’ll try to list some of them here:

    Advantages:

    • Speed. A C function is almost ALWAYS faster than an equivalent objective-c method, because there is no dynamic dispatch needed to call the function

    • Pointers. It is much easier to get a pointer to a C-style function than it is to an Objective-C method, which makes it much better suited for C API callbacks

    Disadvantages:

    • iVars. In a C function, you cannot access the private variables of an object (even with a reference to it), without using runtime wizardry, at which point, it really isn’t worth it.

    • No concept of self. You cannot use the self (or _cmd, for that matter) variables inside a C function, as each C function is independent of other functions inside your product.

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

Sidebar

Related Questions

There are many questions about this PersistenceException, but I have not seen some, where
I have seen this code documented in the tk docs, but I can't figure
I have seen this answer https://stackoverflow.com/a/9243472/563381 And while it works well visual as soon
The answer is probably obvious but I have not seen anything I could use
I have seen this question about deploying to WebSphere using the WAS ant tasks.
I have seen this effect where when mouse is over an image, that image
I have seen this '[A' in a progress bar module but I can't figure
I thought I have seen this somewhere but can't find it any more on
I have seen this kind of code many times before, most recently at scala-user
So I have a bookmarklett that seems to not work on some sites. Here's

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.