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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:19:30+00:00 2026-05-12T09:19:30+00:00

Im learning how to do drag and drop to allow ordering of items in

  • 0

Im learning how to do drag and drop to allow ordering of items in an NSOutlineView. (Its my first time using NSPasteboard).

From the slightly related examples I found online, it seems you use:

[pasteboard setData: data forType: @"myapptype"];

What should be put into the NSData when you are doing a move. The samples put an archived version of the object as the data.

The object attributes could possibly change while the item is being dragged, so doest it make sense that instead I stuff a pointer to the object in there?

  • 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-12T09:19:30+00:00Added an answer on May 12, 2026 at 9:19 am

    No, you generally don’t want to stuff a pointer to an object onto the pasteboard.

    The pasteboard has to have (basically) one of two types of things on it: data, or a promise to provide the data when asked for it. The pasteboard’s lifetime is potentially (and likely) far longer than the lifetime of your application. So imagine this scenario:

    • User copies some data. You put a pointer to your object on the drag.
    • User quits your program. Your object is deallocated.
    • User starts up another instance of your program and hits paste.

    Likely outcome: you crash when the second instance of your program dereferences an invalid pointer.

    What data actually needs to go on the pasteboard can be very specific to your program, but you generally speaking don’t want to put ‘live’ data on there. It’s in your best interests to archive. You may find NSCoder useful for doing simple archiving.

    I will carve an exception here and say one could conceive of doing pointer stuff if it was only ever done for drag and drop (since I don’t think you can do the drag without the program still running) and if you cleared the drag pasteboard when you quit the program. But it’s not a best practice, and I would say that if you’re not very experienced and very aware of the pitfalls, it’s a risky technique.

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

Sidebar

Related Questions

I've just started learning javascript and have created a drag and drop using jquery
When learning C# for the first time, I was astonished that they had no
For the past 5 months or so, I've spent time learning C# using Andrew
I'm learning how to drag-and-drop-move DIV's around the document in javascript. Here is a
I'm trying to implement a simple drag/drop of images between panels using jQuery. While
When learning new languages such as C++ from PHP, does reading other language snippets
I am new to flash and learning action script 3. I am using flex.
In my relatively short time learning OpenCL I frequently see my application cause the
I've only just started learning to build iPhone apps using xcode. I'm slowly getting
Learning jquery, so please be kind :) Using PHP, I have a table with

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.