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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:58:31+00:00 2026-05-17T00:58:31+00:00

Is it possible to pass the pointer to an object in a drag and

  • 0

Is it possible to pass the pointer to an object in a drag and drop operation?

Here is the scenario…

I have an ‘NSArray’ of custom objects. For arguments sake we’ll say this is a list of person objects.

The list is tied to an NSTableView via an NSArrayController. The NSTableView is a drag source and I have an NSView as a drag destination.

When implementing drag and drop I can easily get the name of the currently selected person(s) from the NSArrayController as an NSString in the drag process and pass it to the receiver in the NSView.

However, I would like to be able to pass a pointer to the person object so the receiver has access to the entire object.

The problem seems to be that the drag operation creates a new instance of a person object and does not make a reference to the selected person object despite implementing the required methods in the person model. As a result I get a person object at the destination, it just isn’t populated with the data from the object.

I ideally I want the object pointer because the NSView will make use of the object reference in order that any updates to the object itself are reflected in both the NSView and the NSTableView (and everywhere else the object is used).

Is it even possible to use the object reference in a drag and drop operation or do I need to pass some custom reference that is an iVar of the person object and then do a lookup once it arrives at the destination? (This would seem a little archaic to me considering how much object referencing Obj-c has).

I understand that a target could accept a drag operation from outside the application, but specifying the operation as a local operation would account for this would it not?

I’ve checked the apple docs but still don’t seem to be able to find an answer.

Drag and Drop Programming Topics

Pasteboard Programming Guide

Any and all help much appreciated.

  • 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-17T00:58:31+00:00Added an answer on May 17, 2026 at 12:58 am

    A pasteboard is just a container for data in different types, so whatever you put on the pasteboard must be convertible to data in some type.

    What you need is to give each Person object an identifier of some sort and put that on the pasteboard under a custom type identifier of your own invention. Generally, such an identifier should be the bundle identifier of your application (which should be the reverse of your domain name plus your application name—e.g., com.example.surfwriter) plus the name of the type (e.g., com.example.surfwriter.tabstop).

    When receiving a drop, check for this type. If it’s present, look up the correct object and do whatever you’re supposed to with it. A drag from the table view to the same table view should implement this by moving or copying the object to a new row.

    Don’t use the address of the object—i.e., the object itself—as its identifier. If the object dies (e.g., is deleted), the address will no longer be valid, or may refer to a different object (which may or may not be of the same class as the original object). Use something that you can look up and safely fail to find. This applies to cut/copy and paste more than to drags, but you can and should handle both with pretty much the same code.

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

Sidebar

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.