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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:33:50+00:00 2026-05-20T07:33:50+00:00

I’ve only programmed on the iPhone so far, so Cocoa is sort of confusing

  • 0

I’ve only programmed on the iPhone so far, so Cocoa is sort of confusing in certain ways for me. Here’s where I’ve hit a snag. I wanted my window so that the background was invisible, and without a title-bar. Something like this:

enter image description here

Here’s how I’m doing it:

I set my window‘s class to a custom window, which I’ve created like this:

CustomWindow.h

#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>


@interface CustomWindow : NSWindow {
    @private
    NSPoint initialLocation;
}

@property(assign)NSPoint initialLocation;

@end

CustomWindow.m

//trimmed to show important part
#import "CustomWindow.h"

@implementation CustomWindow
@synthesize initialLocation;

- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag {
    // Removes the window title bar
    self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
    if (self != nil) {
        [self setAlphaValue:1.0];
        [self setOpaque:NO];
    }
    return self;
}

@end

Now, in my .xib file for this window I’ve added a custom view onto the window. I’ve set the view class to a custom class I’ve created that inherits from NSView. Here’s how I’m setting that up:

MainView.h

#import <Cocoa/Cocoa.h>

@interface MainView : NSView {
@private
//nothing to see here, add later
}

@end

MainView.m

//trimmed greatly again to show important part
#import "MainView.h"

@implementation MainView

- (id)initWithFrame:(NSRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
    }

    return self;
}

- (void)drawRect:(NSRect)rect {
    // Clear the drawing rect.
    [[NSColor clearColor] set];
    NSRectFill([self frame]);

}

@end

So here’s my question. I’ve added a NSImageView to my custom view (MainView) in Interface Builder. However, for some reason I can’t figure out how to connect this image view to an instance variable in my custom view. They seem like they can’t be connected like I normally would if I was creating an iPhone app. Any ideas how this would be done?

  • 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-20T07:33:51+00:00Added an answer on May 20, 2026 at 7:33 am

    You connect objects created in your XIB in Mac OS X the same way you do for iOS programs. Just add an NSImageView property to your main view, mark it as an IBOutlet and connect it up.

    For example,

    In MainView.h create a property for your NSImageView and make it an IBOutlet:

    #import <Cocoa/Cocoa.h>
    
    @interface MainView : NSView {
      NSImageView *imageView;
    }
    
    @property(retain) IBOutlet NSImageView *imageView;
    
    @end
    

    In interface builder, make sure the class for the custom view is set to MainView, to do this click on the File’s Owner object in the custom view XIB and then select the identity option in the inspector and enter MainView as the class type.

    Next, CTRL+click File’s owner and drag the arrow to the NSImageView and select the imageView outlet.

    That’s all there is to it. You should be able to reference the image view from code now.

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

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I would like to count the length of a string with PHP. The string
I am trying to understand how to use SyndicationItem to display feed which is

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.