```
int main(int argc, const char * argv[]) {
    NSAppleScript *script = [[NSAppleScript alloc] initWithSource:@"tell application \"Safari\" to return URL of tabs of window 1"];
    NSDictionary *scriptError = nil;
    NSAppleEventDescriptor *descriptor = [script executeAndReturnError:&scriptError];
    if(scriptError) {
        NSLog(@"Error: %@",scriptError);
    } else {
        NSAppleEventDescriptor *listDescriptor = [descriptor  coerceToDescriptorType:typeAEList];
        NSMutableArray *result = [[NSMutableArray alloc] init];
        for (NSInteger i = 1; i <= [listDescriptor numberOfItems]; ++i) {
            NSAppleEventDescriptor *URLDescriptor = [listDescriptor descriptorAtIndex:i];
            [result addObject: URLDescriptor.stringValue];
    }
    NSString *content = [result componentsJoinedByString:@","];

    NSData *fileContents = [content dataUsingEncoding:NSUTF8StringEncoding];
    [[NSFileManager defaultManager] createFileAtPath:@"~/Desktop/foo.txt"
                                            contents:fileContents
                                          attributes:nil];
    NSLog(@"Result: %@", [result copy]);
    }
    return 0;
}

```

The problem with my code right now, is every thing works normally(printing out the array of URLs etc. But when I check I see that foo.txt isn't being created? What is wrong with my application.

and another of my question is on my applescript (2nd line), I can only get URL of window 1, how can I get all windows?

Any answers would be appreciated!