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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:40:07+00:00 2026-05-15T05:40:07+00:00

Could someone please tell me if I am missing something here… I am trying

  • 0

Could someone please tell me if I am missing something here… I am trying to parse individual JSON objects out of a data stream. The data stream is buffered in a regular NSString, and the individual JSON objects are delineated by a EOL marker.

if([dataBuffer rangeOfString:@"\n"].location != NSNotFound) {
  NSString *tmp = [dataBuffer stringByReplacingOccurrencesOfString:@"\n" withString:@"NEWLINE"];
  NSLog(@"%@", tmp);
 }

The code above outputs “…}NEWLINE{…” as expected. But if I change the @”\n” in the if-statement above to @”}\n”, I get nothing.

  • 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-15T05:40:08+00:00Added an answer on May 15, 2026 at 5:40 am

    Why don’t you use – (NSArray *)componentsSeparatedByString:(NSString *)separator? You can give it a separator of @"\n" and the result will be a convenient array of strings representing your individual JSON strings which you can then iterate over.

    if([dataBuffer rangeOfString:@"\n"].location != NSNotFound) {
        NSArray* JSONstrings = [dataBuffer componentsSeparatedByString:@"\n"];
    
        for(NSString* oneString in JSONstrings)
        {
            // here's where you process individual JSON strings
        }
    }
    

    If you do mess with the terminating ‘}’ you could make the JSON data invalid. Just break it up and pass it to the JSON library. There could easily be a trailing space after the ‘}’ that is causing the problem you are observing.

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

Sidebar

Related Questions

Could someone please tell me which objects types can be tested using Regular Expressions
Help! Could someone please tell me what I'm doing wrong? I'm trying to produce
I've recently written this with help from SO. Now could someone please tell me
Can someone please tell me what I am missing. the following sql query returns
Could someone please tell me what is wrong with this code? It works fine
<div>divbox</div> <p>para1</p> <p>para2</p> <p>para3</p> <table class=table><tr><td></td></tr></table> <p>para4</p> <p>para5</p> could someone please tell me how
I have a mystery object in Javascript - please could someone tell me how
Could someone please tell me if there is a way to capture extra joystick
Could someone please tell me how I can make the icon for my app
Could someone please tell me why my code for the jquery autocomplete is not

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.