cocoa

Can a NSManagedObject own another as a property?

I've taught myself Obj-C, and have been self-teaching Cocoa, but adding Core Data to my program has given me nothing but a huge headache, thanks to me needing extensive custom logic. Here are a couple of the questions that are driving me insane. What if I want a Managed Object to own another Managed Object? It seems if I give it a to...

Bidirectional Map in Cocoa

Cocoa provides NSDictionary, which essentially is an associative array. Is there a nice way to get bidirectional associativity? i.e. one way would have been if NSDictionary had a keyForObject: method which mirrored the behavior of objectForKey:. I don't really care if NSDictionary is not the way to get this. I know NSDictionary does pr...

iTunes Scripting Bridge reveal does not work

The following code should show a certain track in iTunes: NSString* iTunesPath = [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:@"com.apple.iTunes"]; iTunesApplication *iTunes = nil; if ( iTunesPath ) { iTunes = [[SBApplication alloc] initWithURL:[NSURL fileURLWithPath:iTunesPath]]; [iTunes setDelegate:self]; }...

How do I share Safari's NSURLCache store?

Background I'm building an app that links recent web pages you've visited together. To do this, I need to get the HTML for recent URLs using Cocoa. Right now, I'm using an invisible WebView to do this. As I understand it, if the URL isn't in the cache for my app, this is hitting web servers. What I want The chances are high that t...

Use NSTask to ssh into another computer

Is there a way I can use NSTask to ssh into another computer (in this case a chumby) and run commands on that device? I also have a password on it. ...

How should I use a help: URL in a Snow Leopard .help bundle?

I'm writing the help book for my application. As required, I have the CFBundleHelpBookName and CFBundleHelpBookFolder keys in my app's info.plist, and I'm using the new Snow Leopard .help bundle format for the help book. The various keys in Rehearsals.help/Contents/Info.plist are all populated as per the Apple Help Programming Guide. As ...

Mike Ash Singleton: Placing @synchronized

I came accross this on the Mike Ash "Care and feeding of singletons" and was a little puzzeled by his comment: This code is kind of slow, though. Taking a lock is somewhat expensive. Making it more painful is the fact that the vast majority of the time, the lock is pointless. The lock is only needed when foo is nil, which ...

How to make an NSOutlineView indent multiple columns?

What would be the easiest or recommended way for making an NSOutlineView indent multiple columns? By default, it only indents the outline column; and as far as I know there is no built-in support for making it indent other columns. I have an NSOutlineView which shows a comparison between two sets of hierarchical data. For visual appeal,...

NSPredicateEditorRowTemplate for date comparison

I'm building an NSPredicateEditor, and I want the ability to do advanced date comparison. I realize that I can build an NSPredicateEditorRowTemplate with a rightExpressionType of NSDateAttributeType, but the predicates I want to build need to be much more advanced than that. For example, I need to basic comparison like: dateKeypath <...

How else can I avoid leaking this Core Foundation object?

The following leaks: CFStringRef labelName = ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(aMultiRef, indexPath.row)); cell.textLabel.text = (NSString *)labelName; CFRelease(labelName); Wondering if there a way to rewrite it so it doesn't leak without breaking out & assigning ABMultiValueCopyLabelAtIndex(aMultiR...

Resizing views in Interface Builder

I'm having trouble visualizing something. Let say I have three views inside a scrollview with some other content. Top, buttons and image. buttons and image are both inside top. Top does NOT fill up the scrollview, however, buttons and image DO fill up top. Top has a maximum size determined at runtime, but it might not all be visible. Th...

Preventing an NSTextField from becoming active (Cocoa OSX)

I want my NSTextFields in my GUI to act like the text fields in the apple finder (the text only becomes active for editing if the text is clicked on when the item is selected). I tried overwriting the mousedown method of the NSTextField to prevent the selection but this did not do the trick. What method do I need to override to accompl...

How to use NSPredicate to catch child objects?

I'm new to core data and try to get all children objects of various types with one query. Say there's an "Animal" type as parent and "Cat", "Dog" and "Bird" as children. I'd like to get both cats and dogs, but not Birds in single query returned as Animal objects. Is it possible? ...

Compare NSArray with NSMutableArray adding delta objects to NSMutableArray

I have an NSMutableArray that is populated with objects of strings. For simplicity sake we'll say that the objects are a person and each person object contains information about that person. Thus I would have an NSMutableArray that is populated with person objects: person.firstName person.lastName person.age person.height And so on. ...

What's SimpleEditableListAppDelegate?

I'm trying to follow the TableView programming guide, and I'm copying the code directly from the guide, but I get "SimpleEditableListAppDelegate undeclared" when I try to compile. Google returns nothing but the programming guide. What's SimpleEditableListAppDelegate, and how do I use it? ...

Problem Building Interface Builder Plugin for Custom NSView Class

I am trying to get a plugin working for Interface Builder. Interface Builder version 3.2. XCode 3.2.1 Mac OS X 10.6.2 MacBookPro5,3 I follow the Quick Start directions on the Apple Developer Site: http://developer.apple.com/mac/library/DOCUMENTATION/DeveloperTools/Conceptual/IBPlugInGuide/Plug-inQuickStart/Plug-inQuickStart.html and...

NSObjectInaccessibleException when sending NSManagedObject as object with NSNotification

I'm getting an NSObjectInaccessibleException when sending NSManagedObject as object with NSNotification. The notification is sent on the same thread as where the NSManagedObjectContext lives. It does not happen at all times and I can't track down what the exception causes. Any ideas? ...

Core Animation unwanted flicker artefact

Hi, I'm using some of the 3D effects in core animation and am noticing a very unpleasant flicker when some of my layers enter into positive territory on the zAxis (just around the point they go behind the "camera" i guess... is there anyway to resolve this? ...

MacOS. SDL. How to hide fullscreen window

Is this possible to hide fullscreen window (SDL based application)? How can I do this? ...

Cocoa Objective-c Property C structure assign fails

Hi All, I want to change the variable value which is a member of a structure of another class. But the value is not getting changed. Here is the code. //Structure.. typedef struct { int a; double b; } SomeType; //Class which has the structure as member.. @interface Test2 : NSObject { // Define some class which uses Some...