• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Performance, Efficiency - Coding practice
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Performance, Efficiency - Coding practice


  • Subject: Performance, Efficiency - Coding practice
  • From: John Ku <email@hidden>
  • Date: Thu, 28 May 2009 16:57:49 -0700

I have this original class with the following method:
- (void) update {
NSString *title = [[NSString alloc] init];
title = @"TEST";

NSPoint drawAtOrigin;
drawAtOrigin.x = 0;
drawAtOrigin.y = 10;

[title drawAtPoint: drawAtOrigin withAttributes: nil];
}


Here, I updated it trying to be efficient:

*.h header file has:*
NSString *title;
NSPoint drawAtOrigin;

*.m file has:*
- (id) init {
drawAtOrigin.x = 0;
drawAtOrigin.y = 10;
}

-(void) update {
[title drawAtPoint: drawAtOrigin withAttributes: nil];
}


Is this a more efficient way to code? Which coding practice is better in
terms of efficiency, memory, performance?
The update method will get called often. So Im thinking there is no need to
create 'NSPoint drawAtOrigin' everytime.
Your thoughts?

Thanks,
John
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Performance, Efficiency - Coding practice
      • From: Shawn Erickson <email@hidden>
    • Re: Performance, Efficiency - Coding practice
      • From: Kyle Sluder <email@hidden>
    • Re: Performance, Efficiency - Coding practice
      • From: Andrew Farmer <email@hidden>
    • Re: Performance, Efficiency - Coding practice
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: performSelectorOnMainThread problem
  • Next by Date: Re: -init never gets sent
  • Previous by thread: Re: -init never gets sent
  • Next by thread: Re: Performance, Efficiency - Coding practice
  • Index(es):
    • Date
    • Thread