I im rewritting m modul to get the MAC Address of a selected EthernetCard This is a part of the C Source
void GetMAC(enx)
{
io_iterator_t intfIterator;
kern_return_t kernResult = KERN_FAILURE;
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// NSLog(@"Detecting Network Interfaces...");
kernResult = FindNetworkInterfaces( &intfIterator );
if( KERN_SUCCESS != kernResult ) {
return ( "findNetworkInterfaces failed\n" );
} else {
/* NSLog( @"Found one of more valid interfaces. Extracting MAC addresses..." );*/
NSDictionary* intfDictionary = GetMACAddresses( intfIterator );
/* ADDED !!! */
/* more portable code than: for( id key in intfDictionary ) { ... */
NSArray* keys = [[intfDictionary allKeys] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
int num = [keys count];
int i;
for (i = 0; i < num; i++)
{
// NSLog( @" %@ => %@", [keys objectAtIndex: i], [intfDictionary objectForKey: [keys objectAtIndex: i]] );
if (i==enx){
printf("%s\n",[[intfDictionary objectForKey: [keys objectAtIndex: i]] UTF8String]);
//printf("%s %s\n",[[keys objectAtIndex: i] UTF8String],[[intfDictionary objectForKey: [keys objectAtIndex: i]] UTF8String]);
//printf( "%s %s\n",[keys objectAtIndex: i], [intfDictionary objectForKey: [keys objectAtIndex: i]]);
return [[intfDictionary objectForKey: [keys objectAtIndex: i]] UTF8String];
}
}
// return [[intfDictionary objectForKey: [keys objectAtIndex: i]] UTF8String];
IOObjectRelease( intfIterator );
}
/* [pool drain]; */
[pool release];
return 0;
}
This is the Funtion of my module:
Function GetMAC(enx:Int)
I Have now the problem what i return [[intfDictionary objectForKey: [keys objectAtIndex: i]] UTF8String]; this shows my any int but not the string itself. What is wrong with my Code. I i use printf("%s\n",[[intfDictionary objectForKey: [keys objectAtIndex: i]] UTF8String]); it show me the MAC Address.
|