• 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
presentError problem: [NSApp presentError ...] doesn't respond.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

presentError problem: [NSApp presentError ...] doesn't respond.


  • Subject: presentError problem: [NSApp presentError ...] doesn't respond.
  • From: "Frederick C. Lee" <email@hidden>
  • Date: Wed, 14 Dec 2005 11:32:49 -0800

Greetings:
I want to process Errors within the NSApp's Delegate "AppDelegate" using the presentError routine: [NSApp presentError...].
An error was encountered within a NSPersistentDocument but I got a notification that the delegate doesn't respond to the presentError.

I've created a copy of the 'attemptRecoveryFromError' routine into my NSPesistentDocument and didn't get the error
(nor did I get any action: the inclosed 'NSLog' didn't fire).

Question: how do I make my NSApplication's Delegate routine aware of errors?

Scenario:
NSPersistentDocument: - source of error.
...
if ([moc save:&error])
NSLog(@"{addNewEntry}. Save *Success*");
else {
NSLog(@"{addNewEntry}. Save *Failure*");
// create a wrapper error that offers a "discard" option
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
[userInfo setObject:error forKey:NSUnderlyingErrorKey];
[userInfo setObject:[error localizedDescription] forKey:NSLocalizedDescriptionKey];
[userInfo setObject:[NSArray arrayWithObjects:@"Discard", @"OK", nil] forKey:NSLocalizedRecoveryOptionsErrorKey]; // (2)
[userInfo setObject:self forKey:NSRecoveryAttempterErrorKey]; // (1)

int k = 0;

NSError *recoverableError = [NSError errorWithDomain:NSCocoaErrorDomain code:k userInfo:userInfo];

[NSApp presentError:recoverableError modalForWindow:theWindow delegate:nil didPresentSelector:nil contextInfo:nil];

...

------------------------------------------------------------------------ ---------------------

NSApp --> AppDelegate - where attemptRecoveryFromError() is located.
...
- (void)attemptRecoveryFromError:(NSError *)error optionIndex
:(unsigned int)recoveryOptionIndex delegate
:(id)delegate didRecoverSelector
:(SEL)didRecoverSelector contextInfo
:(void *)contextInfo {
...
NSLog(@"{GVDocument.m: attemptRecoveryFromError}");
...
} // end attemptRecoveryFromError().
...

The Result:
2005-12-14 11:25:43.684 Global Village[8531] -[NSResponder presentError:modalForWindow:delegate:didPresentSelector:contextInfo:]: T he recovery attempter <NSKVONotifying_GVDocument: 0x351710> doesn't respond to - attemptRecoveryFromError:optionIndex:delegate:didRecoverSelector:context Info:. Ignoring the recovery attempter, options, and suggestion.

What am I missing?

Regards,
Ric.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Prev by Date: Study of Crashes and Leaks in NSURLConnection
  • Next by Date: Build tool
  • Previous by thread: Study of Crashes and Leaks in NSURLConnection
  • Next by thread: Build tool
  • Index(es):
    • Date
    • Thread