I'm just starting Objective C after being pampered with Applescript, and I can't seem to get FSMountServerVolumeSync to work. This is going to seem like a completely beginner question, but how do you pass a parameter from a variable to this action?
Let me explain:
I want to take a variable called *username and set it to the username in this action. I would also like to do this to *url and url. Is there any way someone could show me a sample of how to set this up, from an absolute beginner standpoint?
I am currently reading through tutorials and etc., but I would like to get this section of code done even if I don't exactly understand what I'm doing. ;)
Thanks in advance!
[edit] Here's what I've got so far:
- (IBAction)signin:(id)sender{
NSString * user = @"myusername";
NSString * password = @"mypassword";
NSURL * url = [NSURL URLWithString: @"smb://123.456.789.0"];
NSURL * mountDir = [NSURL URLWithString: @"/Students"];
OSStatus FSMountServerVolumeSync (
CFURLRef url,
CFURLRef mountDir,
CFStringRef user,
CFStringRef password,
FSVolumeRefNum *null,
OptionBits flags);
}
These aren't dumb questions at all.
Remember that CFStringRef and CFURLRef are toll free bridged, which means that the Objective C equivalents are NSString and NSURL. All you need to do is cast.
- (IBAction)signin:(id)sender{
NSString * user = @"myusername";
NSString * password = @"mypassword";
NSURL * url = [NSURL URLWithString: @"smb://123.456.789.0"];
NSURL * mountDir = [NSURL URLWithString: @"/Students"];
OptionBits flags = 0;
OSStatus err = FSMountServerVolumeSync (
(CFURLRef) url,
(CFURLRef) mountDir,
(CFStringRef) user,
(CFStringRef) password,
NULL,
flags);
if(err != noErr)
NSLog( @"some kind of error in FSMountServerVolumeSync - %ld", err );
}
See what I mean so far?
Here is some Apple documentation on toll free bridged types.