cocoa

Problem with NSMutableArray arrayWithObjects:

NSMutableArray *images = [NSMutableArray arrayWithObjects:[UIImage imageNamed:@"JGirl 01.jpg"], [UIImage imageNamed:@"JGirl 03.jpg"], ... , [UIImage imageNamed:@"JGirl 48.jpg"], nil]; self.view = [[[SlideShowView alloc] initWithImages:images byIndex:index] autorelease]; assume that my images contain 48 object but when i de...

Object allocation from class method?

I am just curious if this is right, or bad practice? (i.e. using a class method to alloc/init an instance)? Also am I right in thinking that I have to release the instance in main() as its the only place I have access to the instance pointer? // IMPLEMENTATION +(id) newData { DataPoint *myNewData; myNewData = [[DataPoint alloc] ...

Unable to retrieve selected index from NSComboBox

Im trying to get the selected index of a NSComboBox that has a datasource by using indexOfSelectedItem. [combobox setUsesDataSource:YES]; [combobox setDataSource:dataSource]; [combobox selectItemAtIndex:1]; int idx =[combobox indexOfSelectedItem]; idx will always returns -1; Getting the same results even when defining a internal list...

NSApplicationWillTerminateNotification not received

I have some code that needs to be run when the application terminates. I register my controller for the NSApplicationWillTerminateNotification as follows: [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(applicationWillTerminate:) name: NSApplicationWillTerminateNotification obj...

Cocoa: Return to previous active application?

Hi, is there a way to capture application that was previously active, before my application was brought to front by user? I've tried to this in applicationWillBecomeActive: delegate method, but my application is already mark as active. Thanks. ...

Removing url fragment from NSURL

I'm writing a Cocoa application, which uses NSURLs -- I need to remove the fragment portion of the URL (the #BLAH part). example: http://example.com/#blah should end up as http://example.com/ I found some code in WebCore that seems to do it by using CFURL functionality, but it never finds the fragment portion in the URL. I've encapsu...

NSManagedObject setValue problem (Core Data)

Hi, I wish to edit an existing record in core data. At the moment, I have this code, but it creates a new record (and inserts the correct data into the correct column): NSManagedObjectContext * context = [[NSApp delegate] managedObjectContext]; NSManagedObject * instrument = nil; instrument = [NSEntityDescription insertNewObj...

Am I permitted to change the object graph in NSManagedObjectContextObjectsDidChangeNotification?

I'd like to know when an object has been inserted into my Core Data MOC and when it has, add it to another object with a relationship. So I watch the NSManagedObjectContextObjectsDidChangeNotification notifications find all the objects of the correct class in the set of inserted objects and make the connection using addObject so that t...

How to know a device's name from its device ID in OS X?

Hi all, I'm writing a program in OS X that receives click events from a mouse and a touchpad. When the user clicks at somewhere, the OS sends the device ID, which is just an int, and the position of the cursor to my callback function. I want to know if the click event comes from mouse or touchpad. So, how can I know the device's name fr...

How to get the flash cache file in safari webpage?

Now I am making a safari plug-in for get flash url. and then show it in my webview . But if I downloaded these flash before showing them, it took long time and maybe some time delay. how to find the method to get the flash local cache showing in safari? Thank you very much! ...

How to associate an action to a keyboard shortcut?

Hi all, I've an IBAction that calls up a panel. I want to invoke that action with a keyboard shortcut but I'm at a loss on how to do it. I guess one way of doing it would be to create a menu item, associate the action to the item and then assign the shortcut to that item, but I haven't done my menus yet. Any ideas or suggestions? ...

How do you call PyObjC code from Objective-C?

I'm a long-time Python programmer and short-time Cocoa programmer. I'm just getting started with PyObjC and it's really amazing how easy it it is to get stuff done. That said, I wanted to try using pure ObjC for my controller with PyObjC models. I might be enjoy letting Python be Python and Objective-C be Objective-C. I figured it was wo...

NSPredicate Memory Issues

So I am trying to fix this really annoying bug. If I filter my array like the ideal version with NSPredicate, I will get EXC_BAD_ACCESS because it tries to call release on the object passed in as the delegate an extra time. If I filter with the working version, it works fine. I thought these two implementations were identical. Where am I...

Carbon in Cocoa Crashing: EXC_BAD_ACCESS after NSAutoreleasePool is released

I'm developing a Cocoa user interface for a Photoshop CS3 plugin using Bindings. (Carbon in Cocoa, since PS is a Carbon app) I'm getting a EXC_BAD_ACCESS error when I close my modal NSWindow and the NSAutoreleasePool releases. I believe it has something to do with bindings and the control views I have in my nib file, because when I re...

Making a Cocoa App Pop Up a Widget instead of a Window

I have never made an app using XCode and Cocoa but I think following these instruction: http://developer.apple.com/Mac/library/documentation/GraphicsImaging/Reference/IKImagePicker%5FClass/IKImagePicker%5FReference.html I could easily make an app that pops up a window that allows you to push a button to bring up the IKPictureTaker, but...

Instance variable naming conventions in Cocoa

This question is about variable naming style in objective c and cocoa. I just want to stress that I'm not looking for a "right" answer, just good ideas. I've read through Apple and Google's objective c style guides and I'm not really happy with either of them. Apple's guide doesn't have any real style recommendations regarding instanc...

Is there a way of sharing a Core Data store between processes?

What am I trying to do? A UI process that reads data from a Core Data store on disk. It wouldn't need to edit the data, just read and display the data. A command line process that writes to the same data store as accessed by the UI. Why? So that the command line process can be running all the time but the user can quit the UI proce...

Creating a Cocoa app using C or Perl (NOT Objective-C)

I'm having a hard time understanding how to use Cocoa with either C or Perl. Background: I've seen it mentioned in quite a few places that Mac's Cocoa API can be used with C, Perl etc. but I haven't found any information on how to go about doing this. I've also found a couple of articles saying that Cocoa can be used with Objective-C on...

Null selector sent to first item in NSMutableArray

Whenever I call this method: - (IBAction)addListItem: (id)sender { NSString *newItemText = [inputField stringValue]; TodoItem *newItem = [[TodoItem alloc] initWithGUID:nil text:newItemText]; [newItem autorelease]; [self willChangeValueForKey: @"list"]; [list addObject: newItem]; [self didChangeValueFo...

Does Apples UI define Drag&Drop in menus and/or context menus for menu items

I'm trying to update my GUI a little bit but don't want to run into porting problems later next year when a native Cocoa Port will be started. On Windows/Linux it is common to drag items out of menus or being able to right click on a menu item and display a context menu for this menu item. Is there anything like this on MacOSX. ...