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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:41:12+00:00 2026-06-15T21:41:12+00:00

I have some doubts about unsafe_unretained and weak keywords: as a read they are

  • 0

I have some doubts about unsafe_unretained and weak keywords: as a read they are quite the same and the only difference is that the weak one is set to null if the pointed object is released.

Now I the code below and it crash at point [#2] during the [instanceOfTheView setDelegate:self]

but if in I4vMainView declaration [#1] I substitute

@property (nonatomic, weak) id <I4vDraggingFileProt> delegate;

with

@property (nonatomic, unsafe_unretained) id <I4vDraggingFileProt> delegate;

it works perfectly. What is the reason for this behavior? Thanks

Details: Target 10.7 compiling with ARC. Xcode 4.5.2 . Apple LLVM 4.1

In the class I4vMainView I have:

//----------- I4vMainView.h --------
@protocol I4vDraggingFileProt <NSObject>
   -(void) anURLWasDeopped: (NSURL *) droppedUrl;
@end    

@interface I4vMainView : NSView <NSDraggingDestination>{
    NSImageCell *imageCell;
    NSImage * image;
}

@property (nonatomic, weak) id <I4vDraggingFileProt> delegate;  // [#1]

While in the caller

//----------- I4vViewController.h --------
@class I4vMainView;

@protocol I4vDraggingFileProt <NSObject>
    -(void) anURLWasDeopped: (NSURL *) droppedUrl;
@end

@interface I4vViewController : NSViewController <I4vDraggingFileProt>{
    I4vMainView * mv;
}

-(void) anURLWasDeopped: (NSURL *) droppedUrl;

@end


//----------- I4vViewController.m --------
@implementation I4vViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Initialization code here.
    }
    return self;
}

- (void)loadView{
    mv = [[I4vMainView alloc] init];
    [mv setDelegate:self];    // <-- [#2]
    [self setView:mv];       
}

-(void) anURLWasDeopped: (NSURL *) droppedUrl{
    // ...
}

@end

Add:

With delegate declared as

@property (nonatomic, weak) id <I4vDraggingFileProt> delegate;

i have this Error

<I4vMainView: 0x10060bf40> objc[4773]: cannot form weak reference to instance (0x10061bf10) of class I4vViewController

and back-trace goes thoroughly _objc_trap <- objc_stroreWeak <- -[I4vMainView setDelegate:] <- [I4vViewController view]

enter image description here

  • 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-06-15T21:41:14+00:00Added an answer on June 15, 2026 at 9:41 pm

    I found the answer: as said in weak property for delegate cannot be formed

    You cannot currently create zeroing-weak references to instances of the following classes (emphasis mine):

    NSATSTypesetter, NSColorSpace, NSFont, NSFontManager, NSFontPanel, NSImage, NSMenuView, NSParagraphStyle, NSSimpleHorizontalTypesetter, NSTableCellView, NSTextView, NSViewController, NSWindow, and NSWindowController. In addition, in OS X no classes in the AV Foundation framework support weak references.

    For declared properties, you should use assign instead of weak; for variables you should use __unsafe_unretained instead of __weak.

    In addition, you cannot create weak references from instances of NSHashTable, NSMapTable, or NSPointerArray under ARC.

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

Sidebar

Related Questions

I have some doubts about static_cast and dynamic_cast in C++. Do they completely change
I have some doubts about Newsstand/In-App Purchase that I really can not figure out.
I have some simple doubts about NSOperation and GCD that I have not found
I have some doubts about construction and initialization order guarantees in C++. For instance,
I'm a beginner about javascript, and I have some doubts about the variables of
I have programmed an emulator, but I have some doubts about how to organizate
I have some doubts about the syntax for having structs as members of classes.
I have some doubts about how to concatenate MvcHtmlString instances because of this information
I have an idea of organising a game loop. I have some doubts about
I'm learning Zend Framework, but I have some doubts about the usage and the

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.