Stop execution and get user's choice on iPad app - objective-c

I am writing an app with a synchronization feature. And whenever the app finds a conflict between two objects, i want to display something for the user to choose the correct value.
My first idea was to use UIAlertView but after i create the alert object and show it, the program continues the execution, and may eventually find other conflicts before the user had time to resolve the first one.
My question here is: is there a better approach on this ? Or is there a way to stop the app and wait for the alert's choice ?
Any links, further reading or suggestions are much appreciated. Thanks for your help and time

It depends on how you're setting it up. What you should do is terminate execution of the synchronization when a conflict is found, then start it again from the method called by the alertview.

Related

Square Connect Retrieve Transaction

I've build an iOS app that uses the iOS SquarePointOfSaleSDK which returns me a transaction Id and nothing more. Since I need more information about the payment (e.g: method, how many tenders, etc.) I'm calling the RetrieveTransaction Connect API v2 service immediately when I receive the transaction id from the Square POS app and this normally works, but sometimes I get the error described below.
{"errors":[{"category":"INVALID_REQUEST_ERROR","code":"NOT_FOUND","detail":"Location `XXXXXXXX` does not have a transaction with ID `YYYYYYYYYYYYYYYYYYYY`.","field":"transaction_id"}]}
When this transaction actually exists in this location.
I'm guessing the transaction, sometimes, is not available for API actions that fast, but I couldn't find anything in the documentation about this, I'd really appreciate any help or guidance in this, thank you in advance.
Yes, there can sometimes be a small delay between Charge and the transaction actually being retrievable. Unfortunately I'm not sure on how long the delay can be but I'll make sure this gets added to our documentation.
For now, I would suggest that if the error occurs, just to have the code attempt the RetrieveTransaction call again, perhaps looping until it's available. You should probably also include a way to get out of it (after X time or something), just to prevent the rare possibility of an endless loop.

Updating workflow - new functionality not being used

I'm busy playing around with various things, and am making changes a fair bit for educational purposes.
However, now, any changes I make are not being accepted and old behaviour is still happening. IN this case, I had a email watcher setup to write a file to our domain controller and send an SMS.
I changed it to do something different, but no number of stop and restarts help - it continues to do the first action.
Pointers welcome.
You can try to use the Stop All in the run now screen. This will stop all the workflow instances.
However, if the workflow is set to always on, it will pull up again automatically after a few minutes.
It is best if you disable always on, and set it back to always on.
Hope this helps

When to try data upload again if first sending fails?

In my app (iOS) data upload (http post) sometimes fails (timeout) on bad networks (EDGE).
What is the best strategy for retrying?
Should i retry immediatly or should i wait for "better" network conditions?
How could that be achieved?
There are many ways to handle this, but which you choose very much depends on your application, and how critical the data you're posting is:
Assuming you're doing this in the background (asynchronously), just keep retrying until it works - maybe up to a maximum number of times.
Inform the user and ask them if they want to try again (let them know they need a network connection).
Store a cache of all un-transmitted data and try again after a period of time, or on app restart or when the app is backgrounded.
There's no best strategy - it all depends on the use case for your app.
I would suggest having first try as normal but when it fails, show a UIAlertView with message some thing like: "Couldn't connect to servers, do you want to try again". Place Yes and No button. And when user taps YES, give it another try.

iOS: Handling overlapping background requests

In an iOS app, I'm writing a class that will be messaged, go do a background request (via performSelectorInBackground:withObject:), and then return the result through a delegate method (that will then be displayed on a map). Everything seems to work right when one request is happening at a time, but I'm trying to figure out how to handle multiple overlapping requests. For example, if a user enters something in a search box that starts a background thread, and then enters something else before the initial background thread completes, how should this be handled?
There are a few options (don't let the second request start while the first is in progress, stop the first as soon as the second is requested, let both run simultaneously and return independent results, etc.), but is there a common/recommended way to deal with this?
I don't think there's universal answer to this. My suggestion is to separate tasks (in form of NSOperations and/or blocks) by their function and relationships between them.
Example: you don't want add image resizing operation to the same queue with fetching some unrelated feed from web, especially if no relationship between them exists. Or maybe you do because both require great amount of memory and because of that can't run in parallel.
But you'd probably want to add web image search operations to same queue while canceling operations of the same type added to this queue before. Each of those image search operations might init image resize operation and place it into some other queue. Now you have an relationship and have to cancel resizing in addition to image search operation. What if image search operation takes longer than associated resize operation? How do you keep a reference to it or know when it's done?
Yeah, it gets complicated easily and sorry if I didn't give you any concrete answers because of uniqueness of each situation but making it run like a Swiss clock in the end is very satisfying :)

How to not get NSSearchField freezing?

I've got a NSSearchField, whose action method does all the searching stuff, by analyzing the sender argument (string).
Now the searching stuff (feeding a large array) is kind of CPU intensive, which lets my search field freeze for some seconds.
In other cases i'd detach another NSThread to prevent my GUI from freezing. But in this case that is not possible, because I would detach another ("search") thread everytime the user enters another letter in the search field.
Is there another way of keeping my NSSearchField from freezing?
BTW: My guess is NO, because even the Developoer Documentation's seach field freezes all the time :)
I use GCD. I use an async queue, and the job periodically checks if the current search pattern has changed from what it was called with, and bails if it has. This seems to work quite well.
Can't you use setSendsWholeSearchString: to stop it searching as letters are typed?
Set an NSTimer every time the user types something.
If there's a timer already set, invalidate or reschedule it.
That way, you only get called upon to refresh the search every N seconds, however fast the user types.