I am hitting an url when the server shutdown.Then the program hang up.May i know how to handle the error when the server shutdown.I mean at that situation I want to give an alert.
Thanks in advance
this is in objective-c
Check reachability api code example in cocoa documentation.
The delegate you supply to an NSURLConnection should handle the error. It will receive the -connection:didFailWithError: message in the event that anything goes wrong. Listing 4 here gives a simple example of just logging the error. If you want an alert dialog to appear you can just sent -presentError: with the NSError as a parameter to a view or a NSDocumentController.
Related
I'm trying to understand how to handle errors in obj-c on the MediaPlayer and we had someone do some work to do this for us on the AVPlayer but the way that is handled on AVPlayer is different, from what I can see in the documentation, than how errors are handled on the MPMusicPlayerController.
There is something called an MPErrorDomain which is a type of ErrorDomain.
https://developer.apple.com/documentation/mediaplayer/mperrordomain?language=objc
Do I create an observer to listen for when this type of error object occurs?
I am really just looking to understand how to process when one of these errors occur
https://developer.apple.com/documentation/mediaplayer/mperrorcode?language=objc
Ultimately I want to process these error codes
https://developer.apple.com/documentation/mediaplayer/mperrorcode?language=objc
Do I create an observer to listen for when this type of error object occurs?
No. You just do stuff and either you get an error or you don't.
Some methods have error parameters in their completion handlers:
https://developer.apple.com/documentation/mediaplayer/mpmusicplayercontroller/2582424-preparetoplay
https://developer.apple.com/documentation/mediaplayer/mpmusicplayerapplicationcontroller/2815055-perform
Apart from that, you'll know you've got an error because the Console will say so (during debugging with Xcode).
In the process of learning iOS development and I am currently being taught how to use the core location framework.
I'm told that we need to create an instance of CLLocationManager, and then set a delegate, then implement this method:
-(void) locationManager: (CLLocationManager*)manager
didUpdateToLocation: (CLLocation*)newLocation
fromLocation: (CLLocation*)oldLocation
The book doesn't thoroughly explain how the location is actually received. From what I'm understanding, whenever locationManager logs a new location, it then sends a message (to the delegate?) with the selector being the above method, filling the parameters with the location data? Then we must implement this method and choose what to do with these parameters.
Is this correct? and if not, could someone explain to me exactly what is going on?
Thanks in advance, this is confusing me a ton.
Right, although the message you should implement starting in iOS 6 is -locationManager:didUpdateLocations:. After setting up the delegate, call -startUpdatingLocation and the Location Manager will start sending -locationManager:didUpdateLocations: (or the other method) whenever the location changes until you tell it to stop. Your implementation of that method an do whatever you like -- update a position on a map, log the location to a file, look up the nearest gas stations... There's some reason that you're asking for location updates, and whatever that reason is, this lets you do it.
I have an Adobe Air mobile application that has a NetConnection. One on call to my AMF server it makes the call and everything returns fine. When I make a second call my app crashes.
Anyone one run into this?
you're going to need to get more info. Run it in debug mode and you should get a stack trace, variable values and the like.
Figured it out. My models in the client and on the server didn't match. Why AIR just crash and didn't give me an error is weird.
Maybe your server client is the cause of the error!
It may be the reason of automatic combine of the two amf calls by NetConnection.
So, your function on server side will be run twice.
Check your require or require_one on server side.
I am trying to create a testing application to validate server side error messages. Right now our framework is such that each time a incorrect value is entered in a field and the submit button is clicked and on submission, the error message displayed on the page is captured.
Is there anyway I can bypass this technique, such that the validation happens only in the server side and is passed back to the client side, without having to reload the page each time.
Any other ideas would be much appreciated. Please try to ignore the lameness of the question :( I'm just starting off and wanted to try something new to reduce the time taken to capture the error messages.
Thanks a lot..!!
Use AJAX, Luke!
There are a lot of options to do this. You may use jQuery.ajax for sending your form data to some validation servlet. Or you may use JSF for it. It largely depends on your framework and/or architecture of your application.
I have an application which logs into an online site using POST form being sent from ASIHTTPRequest & ASIFormDataRequest.
I have a log in box, a .xib where user enters their details. Then as they click OK, it connects to the site with the details user has entered. It sends the form OK etc.
But there is a problem. I enter the incorrect details first, it connects and tells me the html of response. I can tell from the html that the details are incorrect. Now i enter the correct details, and ASI* does not even bother connecting.
When I enter the correct details first, it tells me a different html which is supposed to show whenever I enter the right log in details.
So the problem is in cache, because it doesn't bother connecting again on second request, right?
I am using Little Snitch.app, so i know when it connects, and when it does not.
Now, the question sounds: "How do I disable Cache in ASIRequests?"
Thanks a lot.
Snippet of class: http://pastebin.com/a83YCpnm
ASIHTTPRequest doesn't cache POST responses by default - see the following code in ASIHTTPRequest.m
if (![[self requestMethod] isEqualToString:#"GET"]) {
[self setDownloadCache:nil];
}
There's clearly something else going on - are you sure it's a POST request you're making? How are you enabling caching / creating the request, can you post some code please?
Alright I found out what the trouble was. I did not reallocate the ASIFormDataRequest & ASIHTTPRequest on each request, which was causing the trouble on other requests because it was being reused.
Therefore the request has been marked as complete and so it did not even bother making another request if that makes sense.
Thanks