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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:24:36+00:00 2026-06-16T16:24:36+00:00

Let’s say I have a statement which is several lines long: NSString *urlString =

  • 0

Let’s say I have a statement which is several lines long:

NSString *urlString = @"http://www.example.com";
NSURL *url = [NSURL urlWithString:urlString];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];

Is there any benefit to condense it to one line like so?

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL urlWithString:@"http://www.example.com"]];
  • 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-16T16:24:37+00:00Added an answer on June 16, 2026 at 4:24 pm

    The benefit to the one-line version is that you don’t have to create temporary intermediate variables. This is particularly beneficial if you have no other use for those intermediate variables. In some cases it looks neater to use the one-liner but in other situations it can look clunky. There’s no hard-and-fast rule to follow, it is entirely up your own aesthetics. Personally I would choose the one-line version for your scenario but there are probably others that would disagree.

    One time that I know I avoid one-liners is when an initialiser method takes multiple arguments, because it can get messy and hard to follow, especially if you go several layers deep. For a lite example:

    id someObject = [MyClass myClassWithThing:[Thing thingWithX:5 andY:5] supportingThing:[SupportingThing supportingThingWithString:@"Tada!"] error:NULL];
    

    Some people prefer to use Eastern Polish Christmas Tree notation, which would look like:

    id someObject = [MyClass myClassWithThing:[Thing thingWithX:5 andY:5]
                              supportingThing:[SupportingThing supportingThingWithString:@"Tada!"]
                                        error:NULL];
    

    Again, there’s no rule to follow here. Although Objective-C has conventions on how to name classes and methods, I’ve yet to encounter a convention for nested message sending.

    First and foremost, code for readability and maintainability.

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

Sidebar

Related Questions

Let's say I have a method in java, which looks up a user in
Let me explain best with an example. Say you have node class that can
Let me try to explain by example. Say website is hosted at example.com (NOT
Let's say I have a Job Scheduler which has 4 consumers A, B, C
Let's say I have a main folder in my website named test which contains
Let's say I have this interface: // .h @interface DataObject : NSObject { NSString*
Let's say I query for http://images.google.com.sg/images?q=sky&imgcolor=black and I get all the black color sky,
Let's say I have a dataset, which can be neatly classified using weka's J48
Let's have an example like below: package xliiv.sandbox; import android.app.Activity; import android.os.Bundle; import android.util.Log;
Let's say I don't have photoshop, but I want to make pattern files (.pat)

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.