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

The Archive Base Latest Questions

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

Can someone please help me decipher this code? It’s executing when a user pushed

  • 0

Can someone please help me decipher this code? It’s executing when a user pushed a button to submit the data, or in this case, a “question” in the iPhone app.

I know that it’s sending the string to my phpscript.php hosted on the server, but what i’m not familiar with are the long list of commands happening.

NSUserDefaults *p = [NSUserDefaults standardUserDefaults];
[p setObject:[NSString stringWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://website.com/phpscript.php?user=%@&pass=%@&cat=%@&sub=%@&body=%@",[[p valueForKey:@"user"] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],[[p valueForKey:@"pass"] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],sport,@"",[[tvQ.text stringByReplacingOccurrencesOfString:@"\n" withString:@" "] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]]]] forKey:@"q"];
  • 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-16T05:15:33+00:00Added an answer on May 16, 2026 at 5:15 am

    Breaking it down makes it a bit easier.

    NSUserDefaults *p = [NSUserDefaults standardUserDefaults];
    NSString* string1 = [[p valueForKey:@"user"] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
    NSString* string2 = [[p valueForKey:@"pass"] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
    NSString* string3 = [[tvQ.text stringByReplacingOccurrencesOfString:@"\n" withString:@" "] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
    NSString* urlString = [NSString stringWithFormat:@"http://website.com/phpscript.php?user=%@&pass=%@&cat=%@&sub=%@&body=%@",string1,string2,sport,@"",string3];
    id val1 = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString]];
    [p setObject:val1 forKey:@"q"];
    

    So p is a dictionary object loaded from user defaults, looks like some login credentials that are probably saved from last time the app was run.

    stringByAddingPercentEscapesUsingEncoding is a standard method that makes it safe to transmit characters like ‘ ‘ (space) or ‘%’ in a request. It is applied to the strings to ensure the request will reach the server looking like it was intended.

    String1 and String2 are the username and passwords presumably. String3 is the body of the query I guess.

    When the URL is built it executes the query represented by urlString (the code will pause at this point while the fetch is executed – hopefully this whole block is already on a secondary thread). The result of the query is stored in dictionary p and can be accessed through a key @”q”.

    Handling ampersands explicitly:

    [myString replaceOccurrencesOfString:@"&" withString:@"%26" options:NSCaseInsensitiveSearch range:wholeString];
    

    This method can be applied to any string – if it is applied to the same string twice then the second time it will do nothing.

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

Sidebar

Related Questions

Can someone please help me simpling this redundant piece of code? if (isset($to) ===
Can someone please help me understand why this code is not working? $('#quick-search-header.widget-title').css('background-image', 'url(dd_includes/images/icons/sliding-menu-arrow-right.gif)');
can someone please help me out writing this code in objective C : function
Can someone please help me fix this code up? I am getting some weird
can someone please help me with this code, i'm missing something but can't figure
can someone please help me. why does this return an error: Dim stuff As
Can someone please help me out with a JavaScript/jQuery solution for this arithmetic problem:
Could someone please help explain why I can't get this to work? I properly
Please can someone help? I have the following code which uploads a file to
Can someone please help me on this find specific record Edit through MS access

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.