Nathan Denlinger
Nathan Denlinger

Reputation: 139

NSArray to NSMutableArray to NSString

I am using the NetworkExtension Framework (I do have proper entitlements and everything works fine). However, I am trying to access the properties, and did not discover any direct means through the documentation on developer.apple.com. There were properties listed, but no means of accessing them. 1. SSID (NSString) 2. BSSID (NSString) 3. Signal Strength (Double)

I did not see anything in terms of accessing these properties directly, so I decided to get an array of supported interfaces. In my case, I am using Objective-C with NSArray Supported interfaces.

I obtain the array of supported interfaces (current one is the first one). Here is the code that I use to obtain that array.

 NSArray *networkInterfaces = [NEHotspotHelper supportedNetworkInterfaces];

I get this result (I altered the outcome slightly to hide sensitive information:

2016-04-22 14:37:42.263 FlightPath[589:184926] (
"<CNNetwork SSID WiFiNetwork BSSID 00:a0:00:0a:00:0a [protected] [signal 0.884383] [Auto-Join] 0x12f655170>"

)

I am able to log this, and set it to a label/text view. However, I want to use the ObjectAtIndex property so I can populate say a SSID.text (label) with the objectFromIndex.

I have tried numerous of ways to convert the NSArray to a MutableArray, then to a NSString but couldn't get anywhere. Any thoughts, ideas?

Upvotes: 0

Views: 108

Answers (1)

rmaddy
rmaddy

Reputation: 318804

There is no need to create a mutable array. [NEHotspotHelper supportedNetworkInterfaces] returns an array of NEHotspotNetwork objects. That class in turn has properties to get the SSID, BSSID, and signalStrength.

NSArray *networkInterfaces = [NEHotspotHelper supportedNetworkInterfaces];
NEHotspotNetwork *firstNetwork = [networkInterfaces firstObject];
NSString *ssid = firstNetwork.SSID;
NSString *bssid = firstNetwork.BSSID;
double signalStrength = firstNetwork.signalStrength;

Upvotes: 2

Related Questions