PDA

View Full Version : How display memory stats on Label




DavidBlack
Apr 15, 2013, 02:53 PM
Ok I am a average cocoa developer and I am making a app that purge memory. But I want to display the macs memory stats e.g inactive free and wired memory. But I have been having trouble also I want that while the purge command is being run I want the mac to run a progress bar can anyone help me? I have also posted a snapshot.



Sonnestah
Apr 15, 2013, 04:47 PM
Sure, what code do you currently have and what exactly is the issue you're having?

DavidBlack
Apr 15, 2013, 05:04 PM
Sure, what code do you currently have and what exactly is the issue you're having?

Yea sure i used the code from this:
http://stackoverflow.com/questions/6094444/how-can-i-programmatically-check-free-system-memory-on-mac-like-the-activity-mon

But I can't get it to work.

Sonnestah
Apr 15, 2013, 05:11 PM
The code looks just fine, whats the issue/error youre having/getting?

DavidBlack
Apr 16, 2013, 02:09 PM
Sure, what code do you currently have and what exactly is the issue you're having?

I am not sure how to implemented it to connect with a label

ArtOfWarfare
Apr 16, 2013, 02:17 PM
I am not sure how to implemented it to connect with a label

It looks like that code already sets a label, called memLabel, to store that text. So stick it in your controller and hook up an outlet called memLabel to your label in your XIB file.

DavidBlack
Apr 16, 2013, 02:38 PM
Thanks I will try it

DavidBlack
Apr 30, 2013, 02:52 PM
It looks like that code already sets a label, called memLabel, to store that text. So stick it in your controller and hook up an outlet called memLabel to your label in your XIB file.

Thanks but it looks like this still is not working or maybe I am doing something wrong. Can you help I have included the source code if you want to edit or help me.
Please thanks in advance.

ArtOfWarfare
Apr 30, 2013, 10:18 PM
For future reference, please just post the relevant code between [code] and [/ code] tags so it appears right in your post... it's easier to read than having to open a thumbnail. You included the error message, so that's good.

Your error message says it all - there's no property for an NSTextField called text. If you open up the class reference, you can see that that's so, but also, at the top of the class reference, they mention a method by name that I think you'll find helpful. Have a look for yourself, it's in the Overview section:

NSTextField Class Reference (https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSTextField_Class/Reference/Reference.html)

(By the way, you should learn to check the class references. Just Google the name of the class and "Class Reference" and the first result will almost always be the official documentation on the class straight from Apple, and they'll almost always have exactly the information that you want to use the class.)

DavidBlack
May 11, 2013, 11:14 PM
I found not why how to do this can you help me?
I want it to be similar to activity monitor.

Sonnestah
May 12, 2013, 12:21 AM
You need to be more specific, David. I dont think anyone will code your app for you. So please be more specific

Ap0ks
May 12, 2013, 08:35 AM
Thanks but it looks like this still is not working or maybe I am doing something wrong. Can you help I have included the source code if you want to edit or help me.
Please thanks in advance.Using [_memTest setStringValue:[my variable stringValue]]; should fix the error you're getting in your screenshot.