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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:06:56+00:00 2026-06-03T10:06:56+00:00

Ok, so I am very very new to iOS development and also to PHP

  • 0

Ok, so I am very very new to iOS development and also to PHP (well, I know practically nothing about PHP) but I am trying to do the following: my app uses an external key that it retrieves from my server and assign it to an NSString. The problem is that the string gets extra link break (\n) and an extra space and its very annoying to parse. I am guessing that I am doing something wrong cause I don’t see the logic in this. Can someone please explain how I could avoid that?

Here is my code:

NSMutableURLRequest *request = [[NSMutableURLRequest alloc]init];
[request setTimeoutInterval:180.0]; 
[request setURL:[NSURL URLWithString:urlString]]; //url to the getkey.php file 
[request setHTTPMethod:@"POST"];

NSString *key = [[NSString alloc] initWithData:[NSURLConnection    sendSynchronousRequest:request returningResponse:nil error:nil] encoding:NSUTF8StringEncoding];

The PHP file (silly i know, but suppose to do the job, and again, i know nothing about PHP so thats good for me):

<?php

 echo 23204239423;

?> 

“key” gets 23204239423 with an extra space and \n.

  • 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-03T10:06:58+00:00Added an answer on June 3, 2026 at 10:06 am

    You probably have a space after ?> and also a \n (new line). If you remove those from your PHP file, you will probably avoid getting them on HTTP request.

    Having said this, I would probably trim the string from NSString just to avoid having the HTTP server send exactly what the iOS application is expecting. I thing your mobile application parser should be a little bit more flexible with data it’s receiving.

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

Sidebar

Related Questions

Very new to FluentNHibernate, but I'm also excited about the area. I've recently started
I am very new to ios development, I am trying to add some values
I am very new to iOS development, I have an app all set and
I am very new at iOS and objective-c development, so I am struggling with
I'm new to IOS development, and I'm just trying to get my head around
I am VERY new with iOS development. So, please make your response as exact
I'm very new with iOS Development and I have just created one of my
First of all, I am a a very new Objective C/Cocoa iOS Developer but
i am very new to ios development, rather i have just started work on
I'm new for iOS develop. I tried to make a very simple app just

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.