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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:05:41+00:00 2026-06-08T08:05:41+00:00

In title i used Objective C but this question is viable for other OOP

  • 0

In title i used Objective C but this question is viable for other OOP Languages too, my question is this: which of the declarations(samples) below is more efficent?

1)

NSString        *urlString=@"string_literal_for_URL";
NSURL           *url         =   [NSURL urlWithString:urlString];
NSURLRequest    *request     =   [NSURLRequest requestWithURL:url                  cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
                                              timeoutInterval:40];
NSURLConnection *connection  =   [[NSURLConnection alloc] initWithRequest:requestFromLogin 
                                                                 delegate:self];

2)

NSURLRequest *requestFromLogin = [NSURLRequest requestWithURL:[NSURL URLWithString[NSString stringWithFormat:@"http://%@:%@/ipad/login.php?username=%@&password=%@",server.text,port.text,username.text,password.text]]  
                                                  cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
                                              timeoutInterval:40];

[[NSURLConnection alloc] initWithRequest:requestFromLogin delegate:self];

Note: As far as i remember from CS193p Video Lectures iOS is good with lazy instantiation(as far as i understand, the first sample is better) but i’m not sure.. Can anyone please give an answer in OOP point of view.. Thanks in advance

  • 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-08T08:05:43+00:00Added an answer on June 8, 2026 at 8:05 am

    There is a slight difference when the code is compiled with ARC and the optimization is turned off: the first example would increment and decrement a reference count on the url object one extra time. When optimization is turned on, however, the compiler should be able to figure out that the url variable is not used beyond the call to NSURLRequest‘s initializer, and optimize it out.

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

Sidebar

Related Questions

I used to implement this above title by using iframe but now I dont
[ Old question title used to be ARC is set to YES, but xcode
I used this code to change the annotation's color,but after that,the title and subtitle
I've used [[self navigationController] setTitle:@Test Title] to no avail. This is the same way
I have used this code to change a NavigationItem ’s title: self.navigationItem.title = @My
In my project I used navigator.notification.activitystart(Title,Message). But it is just showing the title as
Short version of question: see title Long version of question: I've used jquery's show()
I can write a function this way in Objective-C. This can be used to
How can I display a digit inside the GMarker ? I used title, but
Can CSS be used to change the title attribute in this img tag to

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.