cocoa

problem in reading files in iphone application!

I am reading a file in iphone app. Its Works Fine. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSLog(@"%@",documentsDirectory); NSString *fileName = [NSString stringWithFormat:@"%@/test.txt",documentsDirectory]; ...

NSImage initWithContentsOfFile: display progress

Hello, I'm loading a very big file in an NSimage with this code : [[NSImage alloc] initWithContentsOfFile:aFile] This operation take a few time. I want to display the loading status on my UI. How can it's possible to read or calculate a progression ? Thanks. ...

Using getrusage

Hello Everyone! As a continuation of this question I'm wondering if I can get some simple sample code as to how to make use of getrusage. I would like to use it to find the time CPU used by a process, ideally from the PID. I'm working in Cocoa, Objective_C and of course C. Any help would be awesome! Thanks ...

Is there a way to check if a NSLock was acquired?

Hi, I am working on multithreaded code. Data access is locked in several sections via "NSLock" objects. I want to ensure that some methods which are called within these sections check if their appropriate lock was aquired. Something like: assert([myLock isSet] == YES); I can't find something like "isSet" in NSLock. Any ideas how to ...

How to do bindings from Interface Builder with custom control?

If I want to bind to properties of my custom control from Interface Builder do I need to write my own IB plugin? Will I have to do it programmatically otherwise? ...

Sort NSMutableArray

please help me I want to sort NSMutableArray and yes I can do this by NSSortDescriptor *sortPoint = [[NSSortDescriptor alloc] initWithKey:@"point" ascending:YES]; [hightScore sortUsingDescriptors:[NSArray arrayWithObject:sortPoint]]; but in NSMuatableArray(hightScore), I have 2 NSMutableDictionary like this [item setObject:@"player_n...

NSSound-like framework that works, but doesn't require dealing with a steep learning curve

Hi, I've pretty much finished work on a white noise feature for one of my applications using NSSound to play a loop of 10 second AAC-encoded pre-recorded white noise. [sound setLoops: YES] should be all that's required, right? It works like a charm but I've noticed that there is an audible pause between the sound file finishing and ...

Xcode debugger: Break anywhere in my code following a given line of code

I have a given line of code, after which none of my own code lines should get executed (not in the same "event loop"). How do I configure the Xcode debugger to catch instances in which some of my own code indeed does get executed after this given line of code? If it's not possible to filter by the "event loop", can I filter it down to,...

NSTask to call command top. Getting Error

Hello super-intelligent people! Thanks so much for checking out my post. Right now I'm running this: NSTask *task; task = [[NSTask alloc] init]; [task setLaunchPath: @"/usr/bin/top"]; NSArray *arguments; arguments = [NSArray arrayWithObjects: @"-stats", @"pid,cpu", nil]; [task setArguments: arguments]; NSPipe *pipe; pipe = [NSPipe ...

NSTask spawns top process. How to extract data?

EDIT 1 This code is currently printing to the console. What I would like to do is get the data in a string (and stop the data going to the console) so I can parse it for specific information. I hope my question is clear. Please ask for clarification if needed :) EDIT 2 Another alternative could be to print it to a file and then I co...

How can i add menu items to the context menu of a NSTextField

I tried to overwrite the simple NSView method: - (NSMenu *)menuForEvent:(NSEvent *)event { NSMenu* result = [super menuForEvent: event]; NSMenuItem* mi = [[NSMenuItem alloc] initWithTitle: @"Foobar" action: @selector(foobar) keyEquivalent: @""]; [result addItem: mi]; return result; } but it does not work. It is never c...

Displaying progress indicator inside an NSSearchField

I am using a NSSearchField to run a query over the internet and display the results in a table view. Whilst the query is running I would like to display a progress indicator inside an NSSearchField? I think I have seen this done in another application before. Is there an open source component that I could use to accomplish this? How wo...

Using NSImage operation to make a crop effect

I have an NSView that display an image, and i'd like to make this view acts like a cropping image effect. Then i make 3 rectangles (imageRect, secRect and IntersectRect), the imageRect is the rect which show an image, secRect is rect which just act to darken whole imageRect, and the intersectRect is a rect which like an observe rect, wha...

Padding around an NSTextView in an NSScrollView

I'd like to provide a few pixels of padding around an NSTextView inside of an NSScrollView. I've reviewed this post and using setTextContainerInset does the trick for the left, right, and bottom margins. But as soon as the text scrolls the top buffer is lost. Same thing with overriding textContainerOrigin. Another answer in that post sta...

Recipe for making Cocoa NSDocument packages play well with svn?

I have a tool that writes package-style documents. It's implemented using NSDocument and overrides the following NSDocument methods: - (NSFileWrapper *)fileWrapperOfType:(NSString *)typeName error:(NSError **)outError; - (BOOL)readFromFileWrapper:(NSFileWrapper *)fileWrapper ofType:(NSS...

Writing my own @dynamic properties in Cocoa

Suppose (for the sake of argument) that I have a view class which contains an NSDictionary. I want a whole bunch of properties, all of which access the members of that dictionary. For example, I want @property NSString* title and @property NSString* author. For each one of these properties, the implementation is the same: for the gette...

Using NSNumberFormatter to get a decimal value from an international currency string

It seems that the NSNumberFormatter can't parse Euro (and probably other) currency strings into a numerical type. Can someone please prove me wrong. I'm attempting to use the following to get a numeric amount from a currency string: NSNumberFormatter *currencyFormatter = [[[NSNumberFormatter alloc] init] autorelease]; [currencyFormatte...

Multi threaded confusion objective-c

Hi, I made an application that is written in Cocoa and I happened to see how many threads it was using in Activity Monitor. It said 5. I did not use NSThread or any type of thread capability it registered as 5. Is this automatic? ...

Google Maps http request not working

I am trying to use an http request to google maps to obtain the driving distance between two locations using JSON. However, it seems these are treated different in a browser than in the (iphone) app. I create an NSString which holds the URL, using coordinates and %20 (a space). I NSLog() the URL to make sure, and it seems ok (ie it work...

Cocoa WebView scrollbars won't disappear

I load the webview and set allowsScrolling to NO, but webview still shows scroll bars... Banging your head on your computer hurts a lot more now that MacBooks have sharp metal edges. My code: - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // Insert code here to initialize your application NSString *webF...