objective-cmacosnetwork-programminginterfacesystem.configuration

How to delete network interface of MAC using Objective C


I am working on MAC Application in which i have to create VPN Connection through my application.

I am able to create VPN connection successfully but now I want to delete the interface which was created by my application in network of System Preference.

I tried below code it run successfully but it does not delete that from network list

service = SCNetworkServiceCopy(prefs, (__bridge CFStringRef)(config.serviceID));
Boolean isDeleted = SCNetworkServiceRemove(service);

Is there any other methods to delete the network interface?


Solution

  • Below method delete the interface but we need to save changes what ever we made.

    SCNetworkServiceCopy(prefs, (__bridge CFStringRef)(config.serviceID));
    

    To save setting we need to call the below method to Save changes we made in network.

    SCPreferencesApplyChanges(prefs);