cocoa

Cocoa application appears to crash when the main window is closed

My application seems to have acquired a slightly odd behaviour when it terminates. When I close a the main window using the standard little red button in the top left the application crashes. I haven't made any changes to the application that would obviously cause this problem. I'm struggling to debug the problem because the application ...

Cocoa Application Finished Launch

Is there any way to tell if a Cocoa application, such as Safari, has finished launching and able to respond? I know it's easy to do using delegates within the actual code but that isn't possible for what I'm doing. Thanks ...

Is It Possible to NSLog C Structs (Like CGRect or CGPoint)?

I want to be able to debug C structures without having to explicitly type every property that they consist of. i.e. I want to be able to do something like this: CGPoint cgPoint = CGPointMake(0,0); NSLog(@"%@",cgPoint); Obviously the '%@' won't work, hence the question. ...

How can I reset a cocoa NSSearchField programmatically?

I have a simple cocoa user interface with a list of items and a search field, implemented using NSTableView and NSSearchField, respectively. The data source and all of the bindings are set up and working nicely. I see my data in the list, and I can search through it by typing strings in the search field. As I type in more text, the numbe...

NSTreeController - malloc double free error

I'm using an NSTreecontroller in conjunction with an NSOutlineView in my program, and my program is constantly spitting out: malloc: *** error for object 0x1d70d0: double free. These messages go away when I remove the bindings in IB. Any idea why this is happening? Note: This is behavior is not crashing my program, but I suspect that it...

Convert NSData bytes to NSString?

I'm trying to use the BEncoding ObjC class to decode a .torrent file. NSData *rawdata = [NSData dataWithContentsOfFile:@"/path/to/the.torrent"]; NSData *torrent = [BEncoding objectFromEncodedData:rawdata]; When I NSLog torrent I get the following: { announce = <68747470 3a2f2f74 6f727265 6e742e75 62756e74 752e636f 6d3a3639 36392f...

NSString into NSData

I wanna have a NSString object as NSData. Later this NSData-Object should return his stringValue with: NSData *data; NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; string shouldn't be nil... =D ...

RBSplitView has delayed reload of autosaved view positions.

I really enjoy using RBSplitView, an open source replacement for NSSplitView, but I have a problem in my shipping app and am experiencing it again in a new project. The problem is I'm telling the RBSplitView to autosave its position state by giving it an autosave name. When my app launches the RBSplitView doesn't seem to honor the save...

How to show another swf file in the webview which showing a swf file?

I want to show another swf file in the webview which showing a swf file, and I can get the path of the showing swf file , but when I drap another swf file to the webview which showing swf file , The swf file couldn't be opened, Why ? and some delegate methods of webview I forgot ? Someone can tell me ? Thanks! I followed this example co...

XCode: permanently ignoring warnings

I have a project that compiles with some warnings. It's an iPhone project that uses some methods on NSDate, that are seemingly not the headers of the iPhone SDK, but work flawlessly none the less. When I call these methods I get warnings like: So how do I silence the warnings permanently, in order to tell XCode "it's OK, really." O...

Running Cocoa app under otest causes dyld_misaligned_stack_error in Release mode

Hello, I have a problem which I have been struggling with for a while. I have a Cocoa library which acts as a wrapper for a C++ library. C++ library is tested using a set of BOOST unit tests. The tests run normally under both debug and release modes. In order to test the Cocoa wrapper I am using otest. Here is the strange part, the te...

iPhone use of mutexes with asynchronous URL requests

My iPhone client has a lot of involvement with asynchronous requests, a lot of the time consistently modifying static collections of dictionaries or arrays. As a result, it's common for me to see larger data structures which take longer to retrieve from a server with the following errors: *** Terminating app due to uncaught exception 'N...

How to detect which Space the user is on in Mac OS X Leopard?

Mac OS X Leopard has a virtual desktop implementation called Spaces. I want to programatically detect which space the user is currently on. Cocoa is preferable but AppleScript is acceptable if there's no other way. I've seen a couple of AppleScript implementations, but the techniques they used seemed a bit too hacky to use in producti...

Objective-C 2.0 and Fast Enumeration throwing exceptions

I have a block of code which is similar to the following: for (NSDictionary *tmp in aCollection) { if ([[bar valueForKey:@"id"] isEqualToString:[tmp valueForKey:@"id"]]) { break; } else { [aCollection addObject:bar]; } } Is this technically an exception in Objective-C 2.0? It appears you cannot mutat...

combining animations on single property

Hello all - How can I use two separate CABasicAnimations to simultaneously animate the same property? For example Two CABasicAnimations, both animate position.y. The first animation will be a bounce (from 100, to 300, duration = 1, autoreverse = yes, repeatcount = 10) The second animation will be a slow scroll (by 100, duration = 10)...

Handle OSX Dock Drag N Drop

I looked high and low for information on how to handle drag n drop to the dock in OSX. The drag n drop documentation (http://developer.apple.com/documentation/Cocoa/Conceptual/DragandDrop/DragandDrop.html#//apple_ref/doc/uid/10000069) I found all deal with dragging from view to view. If anyone can point me to some code samples, that woul...

Cocoa-touch and UIButtonContent

Curious, how does an NSMutableArray mutate into a type of UIButtonContent? I'm currently working with an instance variable of type NSMutableArray which crashes upon receiving an error with: *** -[UIButtonContent count]: unrecognized selector sent to instance 0x393ed0 Wasn't even aware of UIButtonContent, so not explicitly working with ...

NULL vs nil in Objective-C

In observeValueForKeyPath:ofObject:change:context: - why do the docs use NULL instead of nil when not specifying a context pointer? ...

How do I debug with NSLog(@"Inside of the iPhone Simulator")?

I'm used to programming and having log messages be viewable. I know you used to be able to use NSLog() to trace out messages when debugging Cocoa apps. What is the best way to "trace" messages when coding in a iPhone XCode development environment? ...

Animate CGContextStrokeEllipseInRect

I'm trying to animate the drawing of a circle. Something the Shazaam app is doing while recording, but much simpler. I've got this code in the drawRect: method to draw the circle: CGContextRef currentContext = UIGraphicsGetCurrentContext(); CGContextSetRGBStrokeColor(currentContext, 0.86, 0.86, 0.86, 1.0); CGContextSetLineWidth(currentC...