How to prevent multiple clicks generating multiple NSOperations - objective-c

I used Marcus Zarra's excellent advice on how to do async downloads using NSURLConnection and NSOperation. I have tied a button press to that NSOperationg.
Question is: how do I prevent the user from spamming the button and shooting off many NSOperations doing the same download over and over again.
I have two concerns:
a) Setting a global variable is probably not a good idea. What happens if the app is suspended with the flag on?
b) Disabling the button upon the first click is probably a bad idea too. If something goes wrong with my code, the button might stay disabled.
I don't really understand what happens if the app is suspened mid-operation, but mostly I'd like to know the "philosophy" of going about this.
I think most ios apps that consume webservices have this exact same problem, but I don't know what's best practice.
Thank you. I looked and this doesn't seem to be a dupe. If it is, I apologize.

One approach is to show a "loading view" which will cover all of the buttons and give information to the user that something is happening. This has the same problems as disabling the button though: you need to make sure you remove it on completion of the operation, or replace it with an appropriate message if something goes wrong

Related

Real-time changes on IDE/Assembler

I'm new on this, sorry for bad usage of terms or overextending an explanation. I'm learning code languages and way i found to bring it to my world so i can learn it better, was coding for/with games i play.
When a window close on the game a function needs to be called, when the character move or you pick an item, everything has a command, function, process or some value of an address change and etc... What i wanted to know is if there something that shows me on real time every call, every value change, address value change, etc...
Nowdays i have to reach some value address by CheatEngine, changing the value till i find the correct address. With this kind of thing i would have a list off things that is happening right now, and a "log" of the past things, then i go to the exact time that i did something, so i would have to look on that peace of the list and discover what did my "something"
Click on a button;
Check on the real-time thing what happened at the time of the "Click
on a button" process;
Discover what call was responsible for that and what it did;
Now i can code something that do what "Click on a button" do, without needing to actually click on that button;
I have seen it somewhere, thats why i'm asking here, if i'm totally wrong and this doesn't exist, i'm sorry, i will delete this post.
I believe a Debugger is what your looking for.
The Debugger in Visual Studio does exactly what your describing, you can see the real time values of your variables and objects at any stage in your program.
You can set 'Break Points' that will halt your code wherever you put them, allowing you to inspect your variables.
You can also 'Step' through your code, which will go line by line through your code, stopping at each line to allow you to inspect.
Here is a good page for an overview of debugging in Visual Studio 2017:
https://msdn.microsoft.com/en-us/library/y740d9d3.aspx

Template 10:Using MasterDetail along with Hamburger Template

I am using template 10 for developing a UWP app and i'm using hamburger template so when a user clicks on a particular category i would like to navigate him to a event list in a master detail view where on left is complete event list in that category and on right selected event details.There is a sample provided and its difficult to understand and don't know how to use the sample in my app along with hamburger navigation.Also as an extra feature if the user clicks on a particular category the hamburger panel should hide and masterdetail view of event should come.And when user click on back button the panel should appear again with that page.
If anyone could help me it would be of great help.Thanks in advance.
There is a really detailed sample in the repository. It has 2 examples in total. 1 a control being developed by a community member. The other is a design based around using basic XAML with visual states along with responsive triggers for screen sizing.
I've implemented the response non-usercontrol variant and it works very well. The other control based scenario has some good features and is being updated often for feature additions and corrections.
Master Detail Sample
I think what you might be looking for here is a slightly simpler thing that we are able to give you. Master/Detail is certainly not splitting the atom. That being said, it's not just a drag and drop thing either. Your are going to need to take a look at the sample. Try to reproduce it exactly into a blank project. It's a great resource, but it's not a control for you to use as much as a sample for you to refer to. I certainly wish I had a simpler answer for you, but this is going to take a little effort on your side to understand the mechanics and implement it. In the end, once you pass that "ah ha" moment, I think you will look back and realize it's simpler than you thought. But until you understand how it works at a fundamental level, it's just going to continue to confuse you. I agree with #mvermef that the visual-state approach (the primary approach) is the easiest and uses the skills you will want to learn for future development, too. But, to that end, please recognize there are TWO approaches in that sample. One uses view-states and the other uses a custom user control. If I were you, don't pick the second approach. The first approach will be easy to understand, easy to implement, and wonderfully helpful to understand for other things later down the road.

How to prevent Intellij IDEA from autofocusing on debugger events?

Got very annoying thing while hard working - Intellij IDEA thinks that I always should have a look at event which is important as it considers.
No, Skyline, it's not such important as you think =)
For example I run a heavy code and while it's running, I'm looking at something else in browser, or making notes in editor AND BANG!!:
since debug breakpoint was met in my application - IDEA makes its window active and overlaps all others.
There were plenty of situations when I was typing smthg, even login info in input fields and in that moment IDEA came on top of windows so I was interrupted, made mistakes, sent info to wrong resource etc. and get angry.
Is there any chance to tell IDEA to be silent at least on debug events?
I want IDEA to switch its window to breakpoint place in code BUT I don't want IDEA to make its ON TOP on my screen at that moment.
thank you.
Try to disable Settings | Build, Execution, Deployment | Debugger | Focus application on breakpoint:

Can you think of some way to remove a button from a compiled vb6 application

We have a VB6 application running at a customer that has a bug in it when the user clicks on the Help button. A quick and easy fix would be to somehow remove the button so that they cannot click it (recompiling isn't an option btw). Possibly a separate app running that is constantly looking for this form and then somehow removing/hiding the button. Can anyone think of a way to do this?
You might be able to find the button window handle using the caption and maybe the class, and then disable it.
This would be pure unadulterated evil, and would sooner or later cause immense pain to you or (worse) an innocent colleague. You really should recompile the application, unless threatened by something worse than a velociraptor.

My.Computer.Keyboard.SendKeys(Keys.PrintScreen, True)

I am attempting to send the PrintScreen key, obviously, which ought to work no matter the window it is focused on. How can I make this trigger the printscreen action like it normally would? This is in VB.net. Thanks for the help!
I have googled this, and couldn't find any results that worked.
EDIT: Somehow, this worked, once. But now it is not working at all!
I would guess that your EDIT note about a successful attempt is actually just that you had manually hit PRNTSCRN previously and that your clipboard still had it in there when you ran you program, which put nothing in the clipboard, but then read your manually taken screenshot out again.
Your approach to get a snapshot of the screen won't work - you have to use some pinvoke stuff, which isn't that hard to piece together if you're patient. http://www.pinvoke.net/ is a great resource.
OOO, and I have never tried this, but this article seems confidently written. http://www.dreamincode.net/code/snippet2572.htm