views:

115

answers:

2

Hi guys

in my app I am trying to run some code that currently exists in my applicationWillTerminate in appDelegate. I have c/p'd the same code into the method that is currently running (verified by NSLog), but the code just doesnt seem to execute the same way.

The following code is from my applicationWillTerminate, which saves data, ready for loading next time.

[myArray makeObjectsPerformSelector:@selector(saveAllDataLeads)];

when I insert this into my DetailViewController.m (in a method that is currently active), I insert the following.

[appDelegate.myArray makeObjectsPerformSelector:@selector(saveAllDataLeads)];

The problem is that it just doesn't do the stuff in saveAllDataLeads, can someone see what is wrong? or is more information required.

Regards

in DetailViewController.h i have declared

MyAppDelegate *appDelegate;

A: 

The objects that you have added to myArray must have a selector with no parameters, named saveAllDataLeads, that is:

@interface MyObject : NSObject {  
}  
- (void)saveAllDataLeads;  
@end  

@implementation MyObject
- (void)saveAllDataLeads {
  // do something
}
@end

Then, presumably somewhere you are adding instances of MyObject to myArray:

MyObject* instance = [MyObject new];
[appDelegate.myArray addObject:instance];
[instance release];
Stuart Carnie
A: 

you only have a short time to do cleanup from that method.(5 sec max?) and if you get close springboard will kill your app off before its done.

drunknbass