nserror

Swift, NSJSONSerialization and NSError

无人久伴 提交于 2020-01-22 13:21:26
问题 The problem is when there is incomplete data NSJSONSerialization.JSONObjectWithData is crashing the application giving unexpectedly found nil while unwrapping an Optional value error instead of informing us using NSError variable. So we are unable to prevent crash. You can find code we are using below var error:NSError? = nil let dataToUse = NSJSONSerialization.JSONObjectWithData(receivedData, options: NSJSONReadingOptions.AllowFragments, error:&error) as NSDictionary if error != nil {

Can reusing the same NSError object be problematic?

亡梦爱人 提交于 2020-01-16 17:35:48
问题 I have since changed my implementation to not do this anymore, but I would be interested in knowing if the following could lead to issues - take for example a process that has multiple steps, each involving passing a reference to an NSError object. If you were to reuse this error object each step along the way, would that reference be negatively effected in some way, perhaps leading to some sort of memory management/dealloc crash? Example (most of the in-between code has been omitted) NSError

how to address the security concern of having an NSException format use a non-string literal

泄露秘密 提交于 2020-01-15 04:16:07
问题 I'm using mailcore2 which is all block based. Typically they define an operation like so SomeMailCoreOp *op = [session getOp]; [op start:^(NSError* error, id result) { if (error) { // handle error code } }]; So what I wanted to do is basically simply throw an NSException every time an error is encountered.. so that I can catch it somewhere else in my code base.. So I created a category for NSError : @implementation NSError (Addons) -(NSString *)description { return [NSString stringWithFormat:

how to address the security concern of having an NSException format use a non-string literal

允我心安 提交于 2020-01-15 04:15:05
问题 I'm using mailcore2 which is all block based. Typically they define an operation like so SomeMailCoreOp *op = [session getOp]; [op start:^(NSError* error, id result) { if (error) { // handle error code } }]; So what I wanted to do is basically simply throw an NSException every time an error is encountered.. so that I can catch it somewhere else in my code base.. So I created a category for NSError : @implementation NSError (Addons) -(NSString *)description { return [NSString stringWithFormat:

NSError localizedDescription always returns english error message

时光怂恿深爱的人放手 提交于 2020-01-14 07:55:29
问题 Why does an NSError * error object with NSURLErrorDomain always return the error.localizedDescription in english ? 回答1: The answer to this question can be found in the project settings. You have to add the language you are interested in to your project Settings: Select the Project in the left navigate select the project (not the target) select the "Info" pane add the language to the "localization" section 回答2: Language is the first available in your project according to your languages order

iOS Game Center - authentication error on one device

我怕爱的太早我们不能终老 提交于 2020-01-12 01:42:27
问题 On one of my devices (an iPad mini running iOS7), when I attempt to authenticate in Game Center I get the dreaded error: Authentication Error: Error Domain=GKErrorDomain Code=2 "The requested operation has been cancelled or disabled by the user." UserInfo=0x15ef0f00 {NSLocalizedDescription=The requested operation has been cancelled or disabled by the user.} I am clearly logged into Game Center. I have completely wiped the app from the device and even a fresh run from Xcode after deleting the

iOS Game Center - authentication error on one device

断了今生、忘了曾经 提交于 2020-01-12 01:42:26
问题 On one of my devices (an iPad mini running iOS7), when I attempt to authenticate in Game Center I get the dreaded error: Authentication Error: Error Domain=GKErrorDomain Code=2 "The requested operation has been cancelled or disabled by the user." UserInfo=0x15ef0f00 {NSLocalizedDescription=The requested operation has been cancelled or disabled by the user.} I am clearly logged into Game Center. I have completely wiped the app from the device and even a fresh run from Xcode after deleting the

this class is not key value coding-compliant for the key error

一曲冷凌霜 提交于 2020-01-06 20:34:26
问题 My problem is when I build the application it has this error Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<FirstViewController 0x717ea40> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key hourTimeOutOfBraceChanged.' Here is my header file #import <UIKit/UIKit.h> #import "Brace.h" @interface FirstViewController : UIViewController @property (weak, nonatomic) IBOutlet UILabel *timeOutOfBraceLabel; @property (weak, nonatomic)

iOS: trigger NSURLErrorServerCertificateUntrusted instead of NSURLErrorCancelled when failing the AuthenticationChallenge

左心房为你撑大大i 提交于 2020-01-06 07:59:44
问题 I'm handling the server trust authentication challenge in a custom way (comparing the public key from the server trust with a hashed local version) through the urlSessionDelegate, similarly to how it is done here: How do I accept a self-signed SSL certificate using iOS 7's NSURLSession and its family of delegate methods for development purposes? As described in the documentation, I need to cancel the challenge if I want to fail the server trust authentication myself. When doing this, my data

CKError localizedDescription

折月煮酒 提交于 2019-12-30 18:56:07
问题 Aim I would like to display the CKError encountered to the user in the app as an alert. So I would like to extract the string from the error that can be displayed to the user. Note: This question is not about UI code to display. Just want to extract a meaningful string from the error. I tried to use localizedDescription but it doesn't seem to contain an appropriate string Code: Given below are the attempts I made: po error <CKError 0x1c464cea0: "Network Unavailable" (3/NSURLErrorDomain:-1009)