Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I'm implementing a system to view the progress of a download in Objective-C, using NSUrlConnetion.
Each time that I receive a part of a file I will send a notification by NSNotificationCenter, but with a file of 500-600 KB, how many message will I have? One for each byte or less? Is this a good way or is it too heavy?
The size of the packets that NSURLConnection receives in the connection:didReceiveData method vary based on the speed of your connection. I've used NSURLConnection for downloading files up to 1.5GB and have always had good results updating a progress bar whenever connection:didReceiveData: is called.
The NSData* that you'll receive ranges from 2kb to 40kb. For small files you're likely to only get one or two connection:didReceiveData: calls before connectionDidFinishLoading: is called.
You will definately have fewer. I'd say that it sounds like a solution that would work.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
How do I access the system temperatures and fan speeds of a Mac using Objective-C? I have seen it done in applications like iStat, but I can not figure out how to do this. Does anyone know how?
You may also take a look at https://github.com/fmorrow/SMCWrapper - it's an object-oriented version of smc.c/smc.h. (The code of SMCWrapper is well commented)
Currently, it opens a connection using IOKit to AppleSMC IOService, and uses it to makes calls to the SMC chip. You can read keys to NSString, but setting key value is experimental at this time.
Take a look at https://github.com/lavoiesl/osx-cpu-temp/blob/master/smc.c for sample code that reads the temps from the SMC.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am decoding an image file: the file has tagged header info mixed with 4K pixel code blocks.
Platform is primarily windows, but could be osx or linux.
Once I read in a code block, I can launch (asynchronously) my decode routine on this block,
while continuing to read the file for header info and code blocks.
Currently, I do synchronous reads using fread(...).
Is is worthwhile to switch to boost asio to asynchronously read in the code blocks?
The read callback could trigger my decode routine. But I wouldn't have to wait for the read
before I carry on to the next code block.
If so, can anyone point me to a reference/tutorial covering boost::asio asynch reads from disk?
There is nothing specific to asio in order to read from disk, you can continue to use your code with fread, at the end of reading you post two new "jobs", one for decoding the previous read, another one for reading next block.
If you want to do "real" multithreading you need a pool of two "io.run()" threads .
Or you can create a pool of x threads, while splitting the read or your entire file in x sections.
Anyway asio is powerfull and very easy to use, but requires a learning curve, may be documentation is missing a tutorial.
IMHO that post is a very good introduction to understand the way to use asio, You should read, and read again ...
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
What I'm trying to figure out is how to automatically save and load data using NSUserDefaults. I know how to do save and load data if I have save and load button, using NSUserDefault. I'm not sure which of the methods I should be using in the AppDelegate, if that is right?
Can somebody point me help me, please?
Thanks
Sam x.
Depends on when (at which point in the lifecycle of the application) you want the loading and saving to happen. The earliest point for loading though I think is when applicationDidFinishLaunching is called.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
What tricks can I do to make my app feel "snappier"?
For example, when I click on a menu button, which loads a different nib file, there is this 1 second delay before the new view shows up, making it feel like the app isn't responsive.
Thank you,
Tee
You could reduce the nib load time by simplifying the content or making some of it load after the view controller appears on-screen.
You can run Instruments on it to try and get an idea of where the choke point is. If it feels unresponsive, compared to other apps, then maybe you're doing something wrong or computationally expensive.
Check that your images are sized correctly. If they're too big that'll up the load time + memory usage.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
In my app which is data collection app i need offline support. Let's say when i am gathering user's data there is no connection on device but once the device comes in network the whole data should automatically goes to the server.
How should i implement this kind of functionality.
Thanks,
Your question is pretty vague, but I assume you're wondering HOW to persist data and not how to automatically send it to the server.
If the data is very simple, NSUserDefaults may suffice.
If you need a bit more complicated data structures, you can use archives.
If you need to store complex object graphs you need to use Core Data.
There's a pretty good guide explaining all of these here.