 |
 |
How do you make a vCard?
|
 |
|
 |
|
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status:
Offline
|
|
I would like to make an app (in Cocoa Java), where the user enters some information into text fields which can then be written to a vCard file. I am a novice programmer with most of my experience in Java. I looked at the "guts" of some vCards and they look pretty easy to format, but I don't know how to write the files to a disk and put the write extension on. I know how to implement NSSavePanel, but not sure where to go from here.
Any help greatly appreciated.
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Jan 2000
Location: Los Altos, CA, USA
Status:
Offline
|
|
If you haven't already, check out the AppKit class:
NSFileWrapper
and the 'writeToFile' method.
When bringing up the NSSavePanel, make sure you setRequiredFileType to be your vcard type. After setting getting the file name from your NSSavePanel, create the NSFileWrapper instance with the path, and execute the writeToFile method.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status:
Offline
|
|
Thanks Brad. I have been checking out the NSFileWrapper class. I was wondering, I have been using the writeFile method for to save a .txt file. I can get it to save the file in the appropriate place, but when I go to the .txt file in the Finder, it is a folder and only alias. Any idea of why this is?
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 2000
Location: Oakland, CA
Status:
Offline
|
|
I have been looking into the same thing, but I have used Applescript Studio though, since I don't know Obj C. However, I do have it working if you want check out what I have let me know. I am using it for storing logins and passwords and addresses when doing various websites. Right now I have it where you can enter the info and it saves to a vCard file for import to the iPod. I plan to add a way to send the file straight to the iPod next. The problem I'm having though is trying to give the saved file a custom .icns file instead of the generic text file.
[ 05-12-2002: Message edited by: exca1ibur ]
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Jan 2000
Location: Los Altos, CA, USA
Status:
Offline
|
|
Originally posted by macrophyllum:
<STRONG>Thanks Brad. I have been checking out the NSFileWrapper class. I was wondering, I have been using the writeFile method for to save a .txt file. I can get it to save the file in the appropriate place, but when I go to the .txt file in the Finder, it is a folder and only alias. Any idea of why this is?</STRONG>
Weird... I haven't tried it lately (and never in Cocoa-Java), but check to see if
yourFileWrapper.isDirectory() returns true (also check out yourFileWrapper.isSymbolicLink() which may make it look like an alias).
Also, when you instantiate your NSFileWrapper, are you using
public NSFileWrapper( String path, boolean symLink)
? If so, is symLink FALSE, and the path a string which does not end with '/'?
In Objective-C, there is a instantiating method 'initRegularFileWithContents:', so there is a bit of a difference...
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status:
Offline
|
|
I got it to work by using the NSData class; it has a writeToURL() method. Now it works great!
I heard that Apple will be releasing some new frameworks for working with vCards, but I don't think they are available yet.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|