• 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
Re: Optimising an app for battery power use?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Optimising an app for battery power use?


  • Subject: Re: Optimising an app for battery power use?
  • From: Hsu <email@hidden>
  • Date: Tue, 15 Mar 2005 10:15:36 -0800

On Mar 15, 2005, at 7:45 AM, Guy English wrote:

Keith Blount <email@hidden> wrote:
In my program I have a text view and I am doing a lot
of things in the -textDidChange delegate method
(updating a lot of other elements that need to reflect
the changes, including a number of calls to the layout
manager to calculate the position of characters and
setting the frames of a number of subviews in another
view). I have worked hard on this, so that speed is
not an issue.

One possible approach, and I haven't seen the app so I'm not sure if this makes sense, would be to delay updates with a timer if you detect the user is really on a roll. You may delay setting the frames of the subviews, for example, by a tiny amount so that they only update on every second or third change to the text view. If the user is typing fast enough a slightly delayed layout of other subviews is unlikely to bother them. I'd try measuring the number of textDidChange calls a second, in code, and if it goes beyond a threshold set a timer with a brief delay that when fired will redo the layout of the subviews. If the timer is already set don't bother - that way you can coalesce the changes and do less work in total.

NSNotificationQueue, with options for coalescing and posting when idle (or at the end of the current event) may be useful in this context.


Karl

--

We can do you free-will and love without the MHz, or MHz and love without the free-will, or all three - consecutive or concurrent. But we can't do free-will and MHz without the love...

Homepage:
     http://homepage.mac.com/khsu/index.html

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Optimising an app for battery power use? (From: Keith Blount <email@hidden>)
 >Re: Optimising an app for battery power use? (From: Guy English <email@hidden>)

  • Prev by Date: email and cocoa
  • Next by Date: Re: email and cocoa
  • Previous by thread: Re: Optimising an app for battery power use?
  • Next by thread: Re: Optimising an app for battery power use?
  • Index(es):
    • Date
    • Thread