Error when inserting data with Xcode 4.2 and ARC

Jan 24, 2012 at 5:55 PM

I've been struggling with this error for several days now to no avail.  It seems that when I try to insert data, the garbage collector is generating an error because the object has already been released.  This is the error I'm getting back from Zombie:   -[CFNumber release]: message sent to deallocated instance

This is my code, which is fairly simple.  It works great the first time I call this method.  It actually works the second time as well, but shortly afterwards the memory exception is raised.  Any suggestions would be greatly appreciated.

-(void) createNewWatchPoint:(int)watchListId watchPointId:(int)watchPointId iso:(NSString *)iso
{
    NSNumber *wlId = [[NSNumber alloc] initWithInt:watchListId];
    NSNumber *ptId = [[NSNumber alloc] initWithInt:watchPointId];

    WebServiceWrapper *proxy = [[WebServiceWrapper alloc] initWithDefaultUri];

     Model_EcDshbrdUsrWtchLstPoints *point = [Model_EcDshbrdUsrWtchLstPoints CreateEcDshbrdUsrWtchLstPointsWithduwlwatchlistid:wlId
                                                                                                                   isoisocode:iso 
                                                                                                                      pointid:ptId];

    [proxy addToEcDshbrdUsrWtchLstPoints:point];
    [proxy saveChanges];
}

Jan 25, 2012 at 8:54 PM

I would like to help, but am in jury duty for the next 3 weeks. Between that and trying to use evenings to avoid getting too far behind on my regular work, I’m not going to be able to help you for a while.

I’m really sorry that I can’t give you a more satisfactory answer than this.

Arlo

From: allachner [email removed]
Sent: Tuesday, January 24, 2012 10:56 AM
To: Arlo Belshee
Subject: Error when inserting data with Xcode 4.2 and ARC [odataobjc:287263]

From: allachner

I've been struggling with this error for several days now to no avail. It seems that when I try to insert data, the garbage collector is generating an error because the object has already been released. This is the error I'm getting back from Zombie: -[CFNumber release]: message sent to deallocated instance

This is my code, which is fairly simple. It works great the first time I call this method. It actually works the second time as well, but shortly afterwards the memory exception is raised. Any suggestions would be greatly appreciated.

-(void) createNewWatchPoint:(int)watchListId watchPointId:(int)watchPointId iso:(NSString *)iso
{
NSNumber *wlId = [[NSNumber alloc] initWithInt:watchListId];
NSNumber *ptId = [[NSNumber alloc] initWithInt:watchPointId];

WebServiceWrapper *proxy = [[WebServiceWrapper alloc] initWithDefaultUri];

Model_EcDshbrdUsrWtchLstPoints *point = [Model_EcDshbrdUsrWtchLstPoints CreateEcDshbrdUsrWtchLstPointsWithduwlwatchlistid:wlId
isoisocode:iso
pointid:ptId];

[proxy addToEcDshbrdUsrWtchLstPoints:point];
[proxy saveChanges];
}

Feb 7, 2012 at 12:33 PM

I finally figured this out and thought I would post the solution for anyone else who might run into this error when they migrate to ARC.  All you have to do is add the compiler flag -fno-objc-arc to your class (the one you generated with odatagen).  I guess this won't be necessary if/when there is an ARC compliant version of OData released.