Where is NSAlert.h in the iOS SDK?

后端 未结 3 1003
逝去的感伤
逝去的感伤 2020-12-11 03:27

According to iOS\'s Using and Creating Error Objects, one can display a error object with the following code.

NSError *theError = nil;
BOOL success = [myDoc          


        
相关标签:
3条回答
  • 2020-12-11 03:42

    NSAlert isn't availble in UIKit. the example it just an copy past of the OS X doc.

    This code in Listing 2-1 uses the returned NSError to display an error alert to the user immediately. (UIAlertView, the UIKit class corresponding to NSAlert, has no equivalent method for alertWithError:.) Error objects in the Cocoa domain are always localized and ready to present to users, so they can often be presented without further evaluation.

    0 讨论(0)
  • 2020-12-11 03:53

    That document is referring to the (OS X) AppKit framework. Right after that box, it says:

    (UIAlertView, the UIKit class corresponding to NSAlert, has no equivalent method for alertWithError:.)

    You can still use UIAlertView, but you'll need to manually populate the title, message, and button strings from the error.

    0 讨论(0)
  • 2020-12-11 03:55

    Its in the AppKit framework. NSAlert

    Import that framework to your project in xcode, then use the #include directive at the top of your code

    there are also some samples of using NSAlert if you go to that page and look at the "Sample Code". I always do that if I'm unsure of any part of a new framework

    0 讨论(0)
提交回复
热议问题