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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:01:22+00:00 2026-05-27T02:01:22+00:00

I am populating a standard UITableViewCell with an image as follows: cell.imageView.image = [UIImage

  • 0

I am populating a standard UITableViewCell with an image as follows:

cell.imageView.image = [UIImage imageNamed:@"someImageName.png"];

Is there a way to have “someImageName.png” be a random png image within my Xcode project? For the record, what I’d really like to do is put similar images in their own directory within the project – e.g. pets, faces, etc, and then depending on the table row select a random image from that directory.

I know I could rename the images using a scheme such as “image_0.png”, “image_1.png” … “image_n.png” and then use a random number x between 0..n to create “image_x.png” – but I’m curious if there’s a way just to retrieve a random .png image file without doing the renaming (or writing the files to local storage, then retrieving a random file from there)?

Thanks very much.

  • 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-27T02:01:23+00:00Added an answer on May 27, 2026 at 2:01 am

    You’ll need to use the - (NSArray *)pathsForResourcesOfType:(NSString *)extension inDirectory:(NSString *)subpath; method of NSBundle class.

    Then just take one random path from that array and get the image with +(UIImage*)imageWithContentsOfFile::(NSString*)fileName; or +(UIImage*)imageWithData:(NSData*)imageData; and the +(NSData*)dataWithContentsOfURL:(NSURL *)url;

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

Sidebar

Related Questions

I have a standard select box which I'm populating using jquery by appending options,
We have mirroring set up between 2 SQL Server 2005 standard editions. There are
If I have a standard HTML textbox: I can retrieve the value using Request.Form.
I'm populating a combobox with month name as follows:` var engCulture = new CultureInfo(en-US);
I have heard that some characters are not present in the Unicode standard despite
I'm populating a datagrid using Linq--standard kind of stuff (code below). For some reason
I have 4 populations with known means and standard deviations. I would like to
I have TreeView Populating from Database And I am Trying to detect the user
I have this code to find the mean and standard deviation of some input
I'm populating a TreeView through a XmlDataProvider, and have already implemented Drag-and-drop functionality, so

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.