내 코코아 프로그램에서 시작시 실행되도록 등록 된 프로그램을 검토하고 해당 목록을 적절하게 수정하려고합니다. Tiger와 호환되기 위해서는 AppleScript로 작업해야하는 것처럼 보입니다. 현재 다음과 같은 코드가 있습니다 :AppleScript를 통해 Objective-C로 Mac OS X 로그인 항목 편집하기
이 명령을 AppleScript로 실행하면 로그인 항목 배열이 반환됩니다. 그러나 Objective-C에서이 배열을 반복하는 방법을 알 수는 없습니다. 좀 더 구체적으로 말하면, 시작할 때 실행되도록 등록 된 프로그램의 이름과 경로를 살펴보고 싶습니다.
아이디어가 있으십니까?
편집 : 나는 이것을 알아 낸 것입니다. 다음은 몇 가지 샘플 코드입니다. 열쇠는 AEKeyword 's를 사용하고 있는데, 매우 잘 설명되어 있지 않습니다. 가장 좋은 참조가 여기에 있습니다 : http://developer.apple.com/mac/library/releasenotes/AppleScript/ASTerminology_AppleEventCodes/TermsAndCodes.html
const AEKeyword aeName = 'pnam';
const AEKeyword aePath = 'ppth';
...
NSDictionary* errorDict;
NSAppleEventDescriptor* getLoginItemsRD = NULL;
NSString *getLoginItemsSrc = @"tell application \"System Events\"\n\
get properties of every login item\n\
end tell";
NSAppleScript *getLoginItemsScript = [[NSAppleScript alloc] initWithSource: getLoginItemsSrc];
getLoginItemsRD = [getLoginItemsScript executeAndReturnError: &errorDict];
[getLoginItemsScript release];
int i;
int numLoginItems = [getLoginItemsRD numberOfItems];
for (i = 1; i <= numLoginItems; i++)
{
NSAppleEventDescriptor *loginItem = [getLoginItemsRD descriptorAtIndex:i];
NSString *loginItemName = [[loginItem descriptorForKeyword:aeName] stringValue];
NSString *loginItemPath = [[loginItem descriptorForKeyword:aePath] stringValue];
}