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

  • Home
  • SEARCH
  • 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 4035484
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:06:14+00:00 2026-05-20T12:06:14+00:00

My Cocoa application displays file icons for all files in a given folder. I’m

  • 0

My Cocoa application displays file icons for all files in a given folder. I’m using this code to get the icon images:

NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:thePath];

Once in a while, the returned icon has no (0) image representations, but a size set to 32×32 (default size as the documentation says), other times the correct icon (as shown in Finder) is returned.

I used to check for nil, but my app would crash later until I discovered that the image was “empty’, so to speak.

When it happens, it is always the same file: a Safari .webarchive (the folder has two webarchives, the icon shows for the first one…).

Is there something special about the code above? This is running in a background thread. Could this be the problem? I can’t imagine why it should be a problem, as no UI elements are updated from that thread.

Thanks! Mark.

  • 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-20T12:06:15+00:00Added an answer on May 20, 2026 at 12:06 pm

    It sounds like you would have to check for some conditions when it is failing i.e. the size == NSZeroSize or the number of image reps is zero, etc… and then have a placeholder image ready for when the returned NSImage is invalid.

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

Sidebar

Related Questions

I'm writing a Cocoa application that displays the contents of an archive file in
I'm writing a Cocoa application that displays the contents of an archive file in
I have a Cocoa application that displays an application-modal alert using the NSAlert class.
I've got a cocoa application that reads in a text file. I'd like to
So, I'm writing a Cocoa application that needs to be able to display web
I am writing a Cocoa application with Mono embedded. I want to run and
I am developing a cocoa application that will be making heavy use of both
I am developing a Cocoa application which communicates constantly with a web service to
How do you set your Cocoa application as the default web browser? I want
How can I dismiss dialog in Cocoa application when user presses Esc or Enter

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.