_UIApplicationHandleEvent deletes data

421 Views Asked by At

My situation: I create an object of singleton class. Object has information about Ivars of another object and some NSStrings field.

-(id)init
 {
      [super init];     

      objectID=[NSString stringWithString:@"sqlRowId"];
      tableNameForBO=[[NSString stringWithString: @"BOComment"] lowercaseString];
      ivarListForBO=class_copyIvarList([BOComment class], &ivarCount);

      return self;
 };

When I call the object it works fine in first time. All fields has right information. But when loading is finished (after applicationDidFinishLunching) application calls _UIApplicationHandleEvent witch delete information in all fields but objectID.

So in program I have pointer to this singleton object that stay constant but his fields has totally wrong information.

NSZombie says:

-[CFString respondsToSelector:]: message sent to deallocated instance 0x6022a10

-[CFString _cfTypeID]: message sent to deallocated instance 0x6022a10

-[CFString _cfTypeID]: message sent to deallocated instance 0x6022bb0

And application crashes with program received signal: “EXC_BAD_ACCESS”.

What can cause this? Haven't any idea.

Thank a lot!

2

There are 2 best solutions below

0
On BEST ANSWER

Thanks a lot! Problem was in not appropriate allocation of object's fields.

After change init method that how:

-(id)init { self=[super init];

objectID=[[NSString alloc] initWithString:@"sqlRowId"];
tableNameForBO=[[NSString alloc] initWithString: [@"BOComment" lowercaseString]];       
ivarListForBO=class_copyIvarList([BOComment class], &ivarCount);    
insertClauseForBO = [[NSString alloc] initWithString: [self getInsertClauseForBO]];

return self;

};

it works just fine!

Thanks a lot for the answer it really helped - knew where to look.

0
On

It seems that your objects have been inadvertently released. You need to make sure that you allocate/retain/release your objects appropriately.

Check out this very nice intro on iOS memory management: http://interfacelab.com/objective-c-memory-management-for-lazy-people/