FSMountServerVolumeSync parameter objective c

和自甴很熟 提交于 2019-12-06 06:06:36

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!