nserror

CKError localizedDescription

牧云@^-^@ 提交于 2019-12-01 17:42:31
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); "The Internet connection appears to be offline."> po error.localizedDescription "The operation couldn

NSURLSession didCompleteWithError:gets called with NSError is nil

痴心易碎 提交于 2019-12-01 08:50:20
Scenario is taking the app to background and foreground multiple times when its uploading is in progress,didCompleteWithError: method is called while taking app to foreground with error parameter is null. Probabilty is 1/3. How do i find out what went wrong as error parameter does not give anything. The problem is that didCompleteWithError report only client side error, otherwise is nil. iOS doc said: "Server errors are not reported through the error parameter. The only errors your delegate receives through the error parameter are client-side errors , such as being unable to resolve the

NSURLSession didCompleteWithError:gets called with NSError is nil

*爱你&永不变心* 提交于 2019-12-01 06:46:05
问题 Scenario is taking the app to background and foreground multiple times when its uploading is in progress,didCompleteWithError: method is called while taking app to foreground with error parameter is null. Probabilty is 1/3. How do i find out what went wrong as error parameter does not give anything. 回答1: The problem is that didCompleteWithError report only client side error, otherwise is nil. iOS doc said: "Server errors are not reported through the error parameter. The only errors your

RestKit Core Data NSError dealloc Crash

拈花ヽ惹草 提交于 2019-11-30 23:17:36
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's somewhere in the RestKit/Core Data mapping or storage? RKManagedObjectRequestOperation

Use of unresolved identifier when using StoreKit constants with iOS 9.3/Xcode 7.3

点点圈 提交于 2019-11-30 20:18:15
I get the error "Use of unresolved identifier" when trying to use one of these StoreKit constants: SKErrorClientInvalid SKErrorPaymentCancelled SKErrorPaymentInvalid SKErrorPaymentNotAllowed SKErrorStoreProductNotAvailable SKErrorUnknown Your code may look like this: if transaction.error!.code == SKErrorPaymentCancelled { print("Transaction Cancelled: \(transaction.error!.localizedDescription)") } What changed? Is there a new module I need to import? As of iOS 9.3 certain StoreKit constants have been removed from the SDK. See StoreKit Changes for Swift for the full list of changes. These

Use of unresolved identifier when using StoreKit constants with iOS 9.3/Xcode 7.3

☆樱花仙子☆ 提交于 2019-11-30 16:55:39
问题 I get the error "Use of unresolved identifier" when trying to use one of these StoreKit constants: SKErrorClientInvalid SKErrorPaymentCancelled SKErrorPaymentInvalid SKErrorPaymentNotAllowed SKErrorStoreProductNotAvailable SKErrorUnknown Your code may look like this: if transaction.error!.code == SKErrorPaymentCancelled { print("Transaction Cancelled: \(transaction.error!.localizedDescription)") } What changed? Is there a new module I need to import? 回答1: As of iOS 9.3 certain StoreKit

swift programming NSErrorPointer error etc

雨燕双飞 提交于 2019-11-30 10:43:16
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 get a new error and cannot make sense of it: NSError! is not a subtype of '@|value ST4' These types

Why is `&` (ampersand) put in front of some method parameters?

我的梦境 提交于 2019-11-30 10:38:21
问题 I'ver wondered, why is it that in front of an NSError, such as below, do we put: &error and not error ? E.g. NSArray *result = [managedObjectContext executeFetchRequest:fetchRequest error:&error]; Hope you can explain, also is this always the way or only in certain situations this is needed? Thanks. 回答1: You need to take the address of error because the function needs to modify it. error is passed by pointer , so you need the "take address" operator & for it. C and Objective-C pass parameters

Swift: Corelocation handling NSError in didFailWithError

谁都会走 提交于 2019-11-30 07:25:00
问题 I'm using CoreLocation to successfully determine the user's location. However when i try to use the CLLocationManagerDelegate method: func locationManager(_ manager: CLLocationManager!, didFailWithError error: NSError!) I run into problems with the error term. func locationManager(manager: CLLocationManager!, didFailWithError error: NSError!) { println("didFailWithError \(error)") if let err = error { if err.code == kCLErrorLocationUnknown { return } } } This results in a 'Use of unresolved

Setting NSError within a block, using ARC

烈酒焚心 提交于 2019-11-30 07:04:06
I wish to set an NSError pointer from within a block in a project using automatic reference counting. What follows is a simplified version of my code: - (BOOL)frobnicateReturningError:(NSError **)error { NSArray *items = [NSArray arrayWithObjects:@"One", @"Two", @"Three", nil]; __block Frobnicator *blockSelf = self; [items enumerateObjectsUsingBlock:^(id item, NSUInteger idx, BOOL *stop) { [blockSelf doSomethingWithItem:item error:error]; }]; } This compiles but given error may be modified by doSomethingWithItem I tried creating a local NSError for the block to modify, which would then be used