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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:36:16+00:00 2026-05-24T21:36:16+00:00

I have a UITableView which uses a UIView subclass for its backgroundView and selectedBackgroundView

  • 0

I have a UITableView which uses a UIView subclass for its backgroundView and selectedBackgroundView properties. Depending on the position (top/bottom round corners), the selection state and some custom detail accessories the views get redrawn.

This might be an expensive operation so I’m thinking about using NSCache for caching some of the drawn views. I’m currently thinking of different approaches:

  • Cache the view depending on its custom properties (not working if a view is used more than once the same time -> fail)
  • Cache the view depending on its custom properties and use a copy of the view (UIView does not conform to NSCopying protocol -> fail)
  • Cache a UIImage representation of the views and assign them in a UIImageView
  • Don’t use NSCache at all or don’t use custom drawing at all?
  • ???

So iOS-performance-tuners, which approach would you prefer?

Thx 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-05-24T21:36:17+00:00Added an answer on May 24, 2026 at 9:36 pm

    Don’t prematurely optimize!

    Clipping the views isn’t that expensive, I have a few apps in the store that scroll at 60FPS while using custom drawn background with drawRect and a roundRect-Mask.

    Creating the selectedBackgroundView is even less problem, since the user actively does a task (tap) and if there’s like 50ms delay for generating the view, nobody will notice.

    Further, NSCache is thread save, so it’s a bit slower and most likely more overhead than you want.

    Regarding “copy of the view” I don’t see any reason why you would want that.

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

Sidebar

Related Questions

I have a UITableView which uses a singleton object as a datasource. I have
In my iPhone app, I have a (non-grouped) UITableView which uses all the bells
I have a UIViewController which uses the UITableViewDelegate and UITableViewDataSource. I have created UITableView
I have very simple iPhone app, which uses just UIButtons , UIlabels , UITableView
I have a UITableView which loads its data from the web. It takes a
I have a UITableView which generates its data from a pList. I have a
I have a UITableView in which each UITableViewCell having a UIView on them and
I have a UITableView which downloads its tableviewcells images from a server. I observed
I have a UITableView which is populated by an array, I have a button
I have a UITableView which displays about 5 cells at a time, yet in

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.