• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: ABPeoplePickerView drag & drop
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ABPeoplePickerView drag & drop


  • Subject: Re: ABPeoplePickerView drag & drop
  • From: Sean Murphy <email@hidden>
  • Date: Tue, 18 Sep 2007 11:27:11 -0400

On Sep 18, 2007, at 6:10 AM, Claus Atzenbeck wrote:

My application uses an ABPeoplePickerView to access the local address
book. I want to drag and drop entries onto the app's main window in
order to create instances which refer to the appropriate ABPerson or
ABGroup.

Is there a sample code out there that demonstrates the drag & drop part
(i.e., how the selected person's/group's IDs are taken to another view)?

Hey Claus,

If there is nothing documented as far as what pasteboard types are actually available from a dragging pasteboard, you can often gain some insight by using the PasteboardPeeker sample code, provided by Apple at <http://developer.apple.com/samplecode/PasteboardPeeker/ index.html>.

ABPeoplePickerView seems to place a variety of data formats onto the dragging pasteboard. Single person drags seem to exist in at least two useful formats, specifically "Apple VCard pasteboard type" and "ABPeopleUIDsPboardType." A likely useful representation of groups exist as "ABGroupsUIDsPboardType."

I could not find these pasteboard type strings declared in any of the ABAddressBook framework's headers, but you can represent them in your code as a simple NSString constants.

Here are some quick examples of creating address book entities using each pasteboard format:

NSData *vCardData = [draggingPasteboard dataForType:@"Apple VCard pasteboard type"];
ABPerson *person = [[ABPerson alloc] initWithVCardRepresentation:vCardData];


Or, a more generic approach:

NSString *recordId = [[draggingPasteboard propertyListForType:@"ABGroupsUIDsPboardType"] objectAtIndex:0];
ABRecord *record = [[ABAddressBook sharedAddressBook] recordForUniqueId:recordId];
(same for "ABPeopleUIDsPboardType")


Admittedly, I never really had a need to deal with the address book API, so there could perhaps exist a better technique for accessing the record information. In general, though, examining PasteboardPeeker's output should provide enough clues as to what data is available and how you can extract it from ABPeoplePickerView's dragging session.

Also, there could be some fragility to this approach as well, since we're manually declaring the types ourselves, and, if the behavior is in fact undocumented, Apple could technically reserve the right to change the implementation of ABPeoplePickerView's dragging source operations.

Hopefully this at least gives you something to work with.

Take care,
-Sean
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: ABPeoplePickerView drag & drop
      • From: Claus Atzenbeck <email@hidden>
References: 
 >ABPeoplePickerView drag & drop (From: Claus Atzenbeck <email@hidden>)

  • Prev by Date: Re: Outline view spontaneously collapsing
  • Next by Date: Re: Spy++ for Cocoa/Mac OS X?
  • Previous by thread: ABPeoplePickerView drag & drop
  • Next by thread: Re: ABPeoplePickerView drag & drop
  • Index(es):
    • Date
    • Thread