nserror

How do I know when a page has failed to load in UIWebView as opposed to being "Stopped" by the user?

Hey Guys, I have a UIWebView within my application which I'm using to provide web browsing functionality. I have a button on my toolbar which calls -(void)stopLoading; on the UIWebView. The problem with this is that when this method is sent to the web view, the delegate receives the - (void)webView:(UIWebView *)webView didFailLoad...

Returning errors in objective-c

Im newish to objective-c and am starting to wonder what is the common/standard/proper way for handling and catching errors? It seems like it might be possible to use NSError to do this, is that a good idea or a hijack of cocoa? ...

NSError question

I have been creating a peer to peer connection for a new game, that does not use the peer picker. I am however dumbstruck as what to i put in here: - (void)session:(GKSession *)session didReceiveConnectionRequestFromPeer:(NSString *)peerID { NSLog(@"I GOTS A CONNECTION REQUEST"); if(connected == YES) { //deny all requests } else if(con...

NSError domains / custom domains - conventions and best practices

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 deali...

NSLog, NSError, bad access

I was doing a rather ordinary addPersistentStore to an NSPersistentStoreCoordinator, and it generated an &error code. So I went to NSLog it, and got an access error when I did this: NSLog(@"Unresolved error %@, %@", error, [error userInfo]); which seems to be the common idiom. When I reformatted the error statement as follows: ...

How to detect and handle HTTP error codes in UIWebView?

I want to inform user when HTTP error 404 etc is received. How can I detect that? I've already tried to implement - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error but it is not called when I receive 404 error. ...

Returning an NSString from an NSError

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? :) ...

EXC_BAD_ACCESS on [error localizedDescription];

This Code trows an EXC_BAD_ACCESS: NSError* error; if(![appdelegate.managedObjectContext countForFetchRequest:request error:&error]) { DLog(@"Failed to save to data store: %@", [error localizedDescription]); NSArray* detailedErrors = [[error userInfo] objectForKey:NSDetailedErrorsKey]; if(detailedErrors != n...

In Objective-C, I'm trying to encapsulate multiple error-able calls and "return" the most useful error.

I put "return" in quotes because I don't want to literally return it. I want to do it similar to how you pass a pointer-to-a-pointer for [NSString stringWithContentsOfFile:usedEncoding:error:]. I would like to make parseFiles:error return nil and have the error reference that was passed in contain the first or second error, depending on...

NSURLErrorDomain error -3001

Hi, 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 ...

Does Apple provide localized recovery options for common NSButton title's for NSError's?

Does Apple provide localized strings for common NSButton titles, such as the equivalents to OK, Cancel, Try Again, and Quit? I'm attempting to create a custom NSError object from one handed to me by another Cocoa framework. I want to implement the NSErrorRecoveryAttempting informal protocol to let the user Try Again or Quit if an error...

Crash invalidates url for NSPersistentStoreCoordinator

I have a Core Data app that has a bug that causes the app to crash and I have not tracked down its cause yet. One of the results of the crash is that the next time the app is started up it can not open the persistent store used by the application previously. The following error is returned from the addPersistentStoreWithType: method: ...

NSString fails, app crashes trying to NSLog the NSError

What it says on the tin. All I want to do is save an NSString to a .txt file in my Documents directory so it can be accessed by the user. This is called in applicationWillTerminate: NSError* err; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths object...

Converting Java to Objective-C: Exception Handling

I'm converting a Java library to Objective-C. The Java code uses exceptions flagrantly (to my Objective-C accustomed mind). When converting, should I be throwing Objective-C exceptions (only within the library; I'll catch them before they leave) or should I use NSError constructs. I'm familiar with the use-case for exceptions in regular...

Best Practice - NSError domains and codes for your own project/app

Hi all, There is a previous SO post regarding setting up error domains for your own frameworks, but what is the best practice regarding setting up error domains and custom error codes for your own project/app? For example, supposing you're working on a Core Data-intensive app with lots of validations, should you just stick with the "of...

NSURL Error Handling

Hi everyone, my app is supposed to make a request from a server every 10 seconds or so with a specific url, change some attributes in the url, and then show the request in another view called "updateView" or if any network error occurred display the error. The first part works fine but if i switch of wifi for example the app crashes. How...

javascript error in jssh in firefox 4.0b1

Using this javascript through jssh compiled and built for the new firefox 4.0 beta 1 returns an odd message. Here is the code (sorry if it's a little messy) In summary the code checks all frames of a firefox window which is a test page of our unit tests for a element that has an onclick which contains the phrase Goodbye Wonderful, inste...

Printing userInfo of an NSError from Core Data throws EXC_BAD_ALLOC

I'm using this code (from http://stackoverflow.com/questions/1283960/iphone-core-data-unresolved-error-while-saving/1297157#1297157) to print a more detailed description of an NSError object: - (NSString*)debugDescription { NSMutableArray* errorLines = [NSMutableArray array]; [errorLines addObject:[NSString stringWithFormat:@"Faile...

[fetchedResultsController performFetch:&error] return NO and error is null after simulated memory warning in background mode

I am running my code in iphone simulator and I put the program in into background use the iPhone simulator menu hardware > simulate memory warning then call the program back to foreground and this code if (![fetchedResultsController performFetch:&error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abo...