nserror

How get the list of errors thrown by a function?

与世无争的帅哥 提交于 2019-12-28 04:23:29
问题 With Swift now some functions are marked with throws , and this force the developers to call the function inside a do - try catch block. But how the developer can know the list of different exceptions thrown by that function? As reference, here is a line of Java code: static void employeeAge(int age) throws MyExceptionA,MyExceptionB Here is clear that the exceptions are 2 MyExceptionA and MyExceptionB and the developer can decide to act differently depends of the error. Can we achieve the

How get the list of errors thrown by a function?

久未见 提交于 2019-12-25 07:05:10
问题 With Swift now some functions are marked with throws , and this force the developers to call the function inside a do - try catch block. But how the developer can know the list of different exceptions thrown by that function? As reference, here is a line of Java code: static void employeeAge(int age) throws MyExceptionA,MyExceptionB Here is clear that the exceptions are 2 MyExceptionA and MyExceptionB and the developer can decide to act differently depends of the error. Can we achieve the

NSURLErrorDomain error -3001

拥有回忆 提交于 2019-12-24 15:48:10
问题 I'm trying to download a file from the internet, but I get the error -3001 back. I've been searching through google but the error doesn't appear on any website, so i have no idea what it means. Can anyone tell me what the error code "NSURLErrorDomain error -3001" means? Thanks 回答1: I wrote an applescript awhile back that can search the header files for error codes. You can find the applescript here. I ran that applescript for your error code and got this from the CFNetworkError.h file. Error

NS_ERROR_FAILURE in SQLite insert

天大地大妈咪最大 提交于 2019-12-24 03:41:07
问题 I just bought a Kobo eReader which forces me to register at their website before the eReader functions. Seeing that I'm quite a privacy fundamentalist I refuse to register to read a couple books, so I went searching for an alternative. This brought me to this blogpost, which suggests to open the SQLite DB on the eReader and manually inserting a user with the following insert (formatted for readability): INSERT INTO user ( UserID ,UserKey ,UserDisplayName ,UserEmail ,___DeviceID

NS_ERROR_FAILURE in SQLite insert

耗尽温柔 提交于 2019-12-24 03:41:02
问题 I just bought a Kobo eReader which forces me to register at their website before the eReader functions. Seeing that I'm quite a privacy fundamentalist I refuse to register to read a couple books, so I went searching for an alternative. This brought me to this blogpost, which suggests to open the SQLite DB on the eReader and manually inserting a user with the following insert (formatted for readability): INSERT INTO user ( UserID ,UserKey ,UserDisplayName ,UserEmail ,___DeviceID

What does “&error” mean in Objective-C? [duplicate]

故事扮演 提交于 2019-12-22 10:44:31
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: why is “error:&error” used here (objective-c) AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error]; What does the & symbol mean in the above code? 回答1: It's the address-of operator; it produces a pointer pointing to the referent. In this case, error is an NSError * ; AVCaptureDeviceInput deviceInputWithDevice:error: takes an address to it and may modify error through

Returning an NSString from an NSError

女生的网名这么多〃 提交于 2019-12-20 15:44:37
问题 I am using the NSURLRequest class in my iPhone app, and the method that calls it returns an NSString which is great for when the connection goes through ok, but the issue is I need to convert the NSError into an NSString so I can either return it back or run some if() statements on it. Any ideas? :) 回答1: -[NSError localizedDescription]. (Also, every ObjC object inherited from NSObject implements -description which returns an NSString.) 回答2: for folks new to objective c (me), following is

RestKit Core Data NSError dealloc Crash

為{幸葍}努か 提交于 2019-12-19 03:59:13
问题 Trying to get to the bottom of an issue I've been seeing in production builds and FINALLY was able to reproduce it while testing. Using RestKit v0.23.1, when doing an RKManagedObjectRequestOperation using the following code (while plugged into instruments) I get "An Objective-C message was sent to a deallocated 'NSError' object (zombie)" and the app crashes every time there's objects in the response JSON - if the response is something like "objects = ();" there's no crash - so I'm guessing it

swift programming NSErrorPointer error etc

可紊 提交于 2019-12-18 13:52:45
问题 var data: NSDictionary = NSJSONSerialization.JSONObjectWithData(responseData, options:NSJSONReadingOptions.AllowFragments, error: error) as NSDictionary; This line of code gives me error NSError is not convertable to NSErrorPointer. So I then thought to change the code to: var data: NSDictionary = NSJSONSerialization.JSONObjectWithData(responseData, options:NSJSONReadingOptions.AllowFragments, error: &error) as NSDictionary; which would turn the NSError error into a NSErrorPointer. But then I

NSError domains / custom domains - conventions and best practices

怎甘沉沦 提交于 2019-12-18 12:27:24
问题 NSError requires a domain, which I understand segments the range of error codes. One would anticipate that there exist somewhere a registry of domain.error code but I've not been able to discover one. Supposedly this could used for looking up localized descriptions for errors. Does anyone have any set of known best practices for dealing with error domains and codes? An authoritative reference (major developers or framework makers) is optimal, but even blogs detailing a good convention is