开发者

iPhone dev - issue with @selector

in my app I am trying开发者_如何学Go 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;


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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜