Hallo,
ich benutze die Bibliothek aus diesem Beispiel von der Apple-Website, um mein Programm den Login Items zuzufügen und es zu entfernen. Letzteres kriege ich nicht hin, weil ich nicht weiss, wie ich an den entsprechenden Index komme. Hier ist mein Code:
Alles anzeigen
value ist nicht NULL, aber hat auch keinen gescheiten wert... Was mache ich falsch?
Gruss
daniel
ich benutze die Bibliothek aus diesem Beispiel von der Apple-Website, um mein Programm den Login Items zuzufügen und es zu entfernen. Letzteres kriege ich nicht hin, weil ich nicht weiss, wie ich an den entsprechenden Index komme. Hier ist mein Code:
Quellcode
- CFArrayRef items;
- CFIndex itemCount;
- CFIndex itemIndex;
- OSStatus status;
- CFDictionaryRef dictRef;
- char * value;
- NSURL * url = [NSURL fileURLWithPath:[[NSWorkspace sharedWorkspace] fullPathForApplication:@"MyApp"]];
- items = NULL;
- status = LIAECopyLoginItems(&items);
- if (status == noErr) {
- itemCount = CFArrayGetCount(items);
- for(itemIndex = 0; itemIndex < itemCount; itemIndex++) {
- dictRef = (CFDictionaryRef) CFArrayGetValueAtIndex(items,itemIndex);
- value = (char *)CFDictionaryGetValue(dictRef,kLIAEURL);
- NSLog([NSString stringWithUTF8String:value]);
- if (strcmp(value,[[url absoluteString] UTF8String]) == 0) {
- status = LIAERemove(itemIndex);
- NSLog(@"status: %d\n",status);
- break;
- }
- }
- }
value ist nicht NULL, aber hat auch keinen gescheiten wert... Was mache ich falsch?
Gruss
daniel
There will always be skeptics.
There will always be disbelievers.
And there will always be Apple to prove them wrong.
There will always be disbelievers.
And there will always be Apple to prove them wrong.
Dein Cast auf NSString hat indirekt geholfen. Damit habe ich bei der Ausgabe eine Exception bekommen, aus der hervorging, dass das zurückgegebene Objekt vom Typ NSURL ist