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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:37:16+00:00 2026-05-27T12:37:16+00:00

I have a window with a custom view object. The custom view displays an

  • 0

I have a window with a custom view object. The custom view displays an image file that is in my project folder by using an NSView class (my NSView class code is shown below).

Now I’m looking for a way to set the image for the custom view to a webpage image address instead of a local image file. Note that this is for a Mac application not a Touch application. As you can see from the implementation that I tried the NSURL approach but it didn’t work, it’s commented out in the code. So basically, how do I put a web image into a desktop window?

NSView header file:

#import <Cocoa/Cocoa.h>

@interface OurView : NSView {
    NSImageView *picture;
}

@end

NSView m file:

#import "OurView.h"

@implementation OurView

- (id)initWithFrame:(NSRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        NSRect rect = NSMakeRect(0, 0, 500, 500);
        picture = [[NSImageView alloc] initWithFrame:rect];
        [picture setImageScaling:NSScaleToFit];
        [picture setImage:[NSImage imageNamed:@"earth.jpg"]];
        //[picture setImage:[NSURL URLWithString:@"http://curious.astro.cornell.edu/images/xraysun.gif"]];
        [self addSubview:picture];
    }

    return self;
}

- (void)drawRect:(NSRect)dirtyRect {
    // Drawing code here
}

@end
  • 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-27T12:37:16+00:00Added an answer on May 27, 2026 at 12:37 pm

    Try:

    [picture setImage: 
        [[[NSImage alloc] initWithContentsOfURL:
            [NSURL URLWithString:@"http://..."]] autorelease]];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom view that draws an CGImage using: - (void) drawImage {
I have an NSScrollView that fills an entire window and displays a huge image.
I have a window which has a custom NSView and has a bottom bar
I have a custom view in a .xib file, which I use as the
I have a custom view that's not getting layoutSubview messages during animation. I have
I have question about NSView: Imagine a Custom View where the mouseDown, mouseDrag and
I have a simple project which consists of a simple window with one view
I have a nib file. In this I created a new custom view (of
I have a single window with a single custom view in it, and I
I have a windows service that has a custom configuration section. In the configSectionHandler

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.