• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Error creating object CWConfiguration
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Error creating object CWConfiguration


  • Subject: Error creating object CWConfiguration
  • From: Marcel Sanchez Gongora <email@hidden>
  • Date: Wed, 27 Jul 2011 05:30:16 +0000

Dears macnetwork coders,  

I am try to make one POC where I created a CWWirelessProfile that I wish to save as a preferred network. The example that a try to use was posted on stackoverflow [1]  but I can't to do run it.
The problem is rare because some minutes before I was able to make run it. But now a runtime exception is launched always after clean and build. I can't explain me why this happen . As I how you below in the gdb message snipped, the problem happen on this line:
WConfiguration *conf = [airport configuration]; 
the gdb say: "attempt to insert nil" but I don't know why this error.

I would appreciate any comments about it

thanks in advanced and sorry by my english I am spanish speaker  


[1] http://stackoverflow.com/questions/3072749/programmatically-created-airport-connection-persistence
----------8<----------[POC]----------8<----------8
#import <CoreWLAN/CoreWLAN.h>
#import <SecurityFoundation/SFAuthorization.h>

int main( int argc, const char *argv[] ) {

    

    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    NSString *interface = @"en1";

    CWInterface *airport = [CWInterface interfaceWithName:interface];

    CWWirelessProfile *newProfile = [CWWirelessProfile profile];

    [newProfile setSsid:@"wep-poc"];
    [newProfile setSecurityMode:[NSNumber numberWithInt:kCWSecurityModeWEP]];
    [newProfile setPassphrase:@"wepexample201"];

    CWConfiguration *conf = [airport configuration];


    BOOL configChanged =NO;
    NSSet *rememberedNetworks = [conf rememberedNetworks]; 
    if (![ rememberedNetworks containsObject:newProfile]){
        [conf setRememberedNetworks:[rememberedNetworks setByAddingObject:newProfile]];
        configChanged =YES;
    }


    NSArray *preferredNetworks = [conf preferredNetworks];
    if (![preferredNetworks containsObject:newProfile]){
        [conf setPreferredNetworks:[preferredNetworks arrayByAddingObject:newProfile]];
        configChanged =YES;
    }


    if (!configChanged ){
NSLog(@"La red no fue cambiada.");
        return 1;
    }
    SFAuthorization *authorization = [SFAuthorization authorization];
    BOOL authResult =[authorization obtainWithRight:"system.preferences"
                                              flags:(kAuthorizationFlagExtendRights | 
                                                     kAuthorizationFlagInteractionAllowed | 
                                                     kAuthorizationFlagPreAuthorize)
                                              error:NULL];  

    if (!authResult){

NSLog(@"Error de autenticacion.");
       return 1;
    }
    [airport setAuthorization:authorization];


    NSError *err =nil;;

    BOOL saved = [airport commitConfiguration:conf error:&err];
    if (!saved && err){
        NSLog(@"La red no fue agregada.");
        return 1;
    }

    if (!saved){

        NSLog(@"Error.");
return 1;
    }
    [pool release];
    return 0;
}

----------8<----------[ERROR]----------8<----------

2011-07-27 04:24:16.185 consolaWifi[2290:a0f] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFArray insertObject:atIndex:]: attempt to insert nil'
*** Call stack at first throw:
(
0   CoreFoundation                      0x00007fff83f29444 __exceptionPreprocess + 180
1   libobjc.A.dylib                     0x00007fff85f4c0f3 objc_exception_throw + 45
2   CoreFoundation                      0x00007fff83f29267 +[NSException raise:format:arguments:] + 103
3   CoreFoundation                      0x00007fff83f291f4 +[NSException raise:format:] + 148
4   Foundation                          0x00007fff849a4c52 -[NSCFArray insertObject:atIndex:] + 119
5   CoreWLAN                            0x000000010001b769 -[CWConfiguration initWithInterface:] + 577
6   CoreWLAN                            0x00000001000141d1 -[CWInterface configuration] + 53
7   consolaWifi                         0x0000000100000fd0 main + 248
8   consolaWifi                         0x0000000100000ed0 start + 52
9   ???                                 0x0000000000000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: SOCKS proxy support
  • Next by Date: Re: SOCKS proxy support
  • Previous by thread: Re: SOCKS proxy support
  • Index(es):
    • Date
    • Thread