"Open Document"(odoc) 이벤트에 대한 응답 인 응용 프로그램 코드가 있습니다. 맥 OS X 타이거와 레오파드,이 코드는 잘 작동 :Snow Leopard의 "Open Document"(odoc) 이벤트 처리
맥 OS X 스노우 레오파드 (Snow Leopard)에서- (void) handleOpenDocumentEvent:
(NSAppleEventDescriptor*)event
withReplyEvent:(NSAppleEventDescriptor*)replyEvent
{
NSAppleEventDescriptor const *const dirObj =
[event descriptorForKeyword:keyDirectObject];
DescType const dirObjType = [dirObj descriptorType];
if (dirObjType == 'alis') {
//
// Open a single file.
//
NSData const *const data = [dirObj data];
AliasHandle const fileHandle =
reinterpret_cast<AliasHandle>(::NewHandle([data length]));
if (fileHandle) {
[data getBytes:*fileHandle];
err = [self queueFile:fileHandle fromSender:senderSig];
}
} else if (dirObjType == 'list') {
//
// Open multiple files.
//
AliasHandle fileHandle =
reinterpret_cast<AliasHandle>(::NewHandle(0));
if (fileHandle) {
int const numItems = [dirObj numberOfItems];
for (int i = 1; i <= numItems; ++i) {
NSData const *const data = [[dirObj descriptorAtIndex:i] data];
::SetHandleSize(reinterpret_cast<Handle>(fileHandle), [data length]);
if ((err = ::MemError()) != noErr)
break;
[data getBytes:*fileHandle];
err = [self queueFile:fileHandle fromSender:senderSig];
if (err != noErr)
break;
}
}
}
}
그러나,이 코드는 작동하지 않습니다. 'ALIS'유형이 새으로 대체되었습니다
{ 1 } 'aevt': aevt/odoc (i386){
return id: 5173 (0x1435)
transaction id: 0 (0x0)
interaction level: 112 (0x70)
reply required: 0 (0x0)
remote: 0 (0x0)
for recording: 0 (0x0)
reply port: 81695 (0x13f1f)
target:
{ 1 } 'psn ': 8 bytes {
{ 0x0, 0x17c17c } (iPhoto)
}
fEventSourcePSN: { 0x0,0x17c17c } (iPhoto)
optional attributes:
< empty record >
event data:
{ 1 } 'aevt': - 1 items {
key '----' -
{ 1 } 'list': - 1 elements {
{ 1 } 'bmrk': 944 bytes {
000: 626f 6f6b b003 0000 0000 0110 1000 0000 book............
001: c002 0000 0500 0000 0101 0000 5573 6572 ............User
002: 7300 0000 0300 0000 0101 0000 706a 6c00 s...........pjl.
003: 0800 0000 0101 0000 5069 6374 7572 6573 ........Pictures
004: 0e00 0000 0101 0000 6950 686f 746f 204c ........iPhoto L
005: 6962 7261 7279 0000 0800 0000 0101 0000 ibrary..........
006: 4d6f 6469 6669 6564 0400 0000 0101 0000 Modified........
007: 3230 3037 0b00 0000 0101 0000 4a75 6e20 2007........Jun
008: 392c 2032 3030 3700 0c00 0000 0101 0000 9, 2007.........
009: 494d 475f 3633 3837 2e6a 7067 2000 0000 IMG_6387.jpg ...
....
058: 0000 0000 30f0 0000 3002 0000 0000 0000 ....0...0.......
}
}
}
}
: 여기
{ 1 } 'aevt': aevt/odoc (i386){
return id: 1012269061 (0x3c560005)
transaction id: 0 (0x0)
interaction level: 112 (0x70)
reply required: 0 (0x0)
remote: 0 (0x0)
for recording: 0 (0x0)
reply port: 150031 (0x24a0f)
target:
{ 1 } 'psn ': 8 bytes {
{ 0x0, 0x655655 } (iPhoto)
}
fEventSourcePSN: { 0x0,0x655655 } (iPhoto)
optional attributes:
< empty record >
event data:
{ 1 } 'aevt': - 1 items {
key '----' -
{ 1 } 'list': - 1 elements {
{ 1 } 'alis': 326 bytes {
/Users/pjl/Pictures/IMG_8501.JPG
}
}
}
}
스노우 레오파드 시스템에서 AppleEvent의 덤프입니다 : 여기에 레오파드 시스템에서 AppleEvent의 덤프입니다 스노우 레오파드 "북마크"유형. 이 코드를 수정하는 방법 있도록 :
A)에 대한 테스트 및 새로운 'bmrk'유형, 즉, 파일B의 절대 경로를 가져올를) 처리가 타이거와 레오파드에 계속 작동
?
또는 OS에 'alis'구조가 포함 된 odoc 이벤트를 원한다고 말할 수있는 방법이 있습니까?
고마워요! 내 종료 코드는 AliasHandles를 사용합니다. NSURL을 그 중 하나로 변환 할 수있는 방법이 있습니까? 문서는 쉬운 방법이없는 것으로 보입니다. –
NSURL -> AliasHandle에서 직접 이동할 방법이 없습니다. 먼저 CFURLGetFSRef()를 사용하여 FSRef로 변환 한 다음 FSNewAlias ()를 사용하여 별칭을 만듭니다. –