cocoa

NSCollectionView: Can the same object not be in the array more than once or is this a bug?

I may be doing this all wrong, but I thought I was on the right track until I hit this little snag. Basically I was putting together a toy using NSCollectionView and trying to understand how to hook that all up using IB. I have a button which will add a couple of strings to the NSArrayController: The first time I press this button, my...

Notifications for file system changed?

I'm implementing a free space on disk bar where while files are being copied, the free space bar updates. I need some way of being notified of file system changes. What's the best way to go about doing this? ...

Menu Items, Responder Chains, and NSViewController, Oh My!

I must be missing something simple, but I can't see it. First, the setup: DATreeView, a subclass of NSView DATreeViewController, a subclass of NSViewController MainMenu.xib has an instance of DATreeViewController, which is configured to load a view from DATreeView.xib MainMenu.xib also has an instance of DendreaAppDelegate, which has ...

Retain Count & Copy In Setter?

This is a followup question from a previous question, which is hopefully a little clearer. I am just curious how the code presented below is working, specifically is the variable myString getting released. It does not look like it is from the output? CODE // IMPLEMENT @implementation CelestialBody - (void)setName:(NSString *)newName{ ...

Returning errors in objective-c

Im newish to objective-c and am starting to wonder what is the common/standard/proper way for handling and catching errors? It seems like it might be possible to use NSError to do this, is that a good idea or a hijack of cocoa? ...

Ok to release a pointer thats nil?

If I create a new object that includes two object pointers (see below) when the object is created the pointers are set to point to nil; @interface rocketShip : NSObject { NSString *name; NSNumber *thrust; } If (for some unexpected reason) I don't assign these pointers and later release them in my dealloc method is that ok, I ...

Binding NSSlider to NSTextField with nil minValue?

I have an NSSlider bound to a text field to display the value given by the slider. Everything works, but I would like the NSSlider to send "nil" as minValue to the object. For example, I can convert it to nil when saving (to a propertylist): if ([myOb intValue] > 0) [myDict setObject:... forKey:...] But I would like to apply sa...

Loading a wallpaper (or background layer) in a Cocoa app

I have created a very minimal OS X install on a USB stick to use as emergency boot media. Basically what the install is, is a clone of the Mac OS X Install DVD with the installer and packages stripped out. I have my own launch daemon starting an app launcher when the install starts. The problem right now is that the wallpaper is just a ...

Dot notation dealloc?

@property (copy) NSString *name; @property (copy) NSString *orbit; @property (copy) NSNumber *mass; @property float surfaceTemp; @property float rotationSpeed; Currently Have this - (void)dealloc{ [name release]; name = nil; [orbit release]; orbit = nil; [mass release]; mass = nil; [super dealloc]; } If I...

How to send a "Cmd-C" keystroke to the active application in objective-c, or tell the application to do a copy operation?

Getting the active application is not a problem, I already have this implemented. What I want to know is how to send a "Cmd-C" key combination to the active application so it puts the selected text in the clipboard (general pasteboard). Or even better: how to tell the active application to do a copy operation without sending the keystr...

Getting an Uniform Type Identifier for a given extension

Hello, I'm trying to find some way in Cocoa to translate from file extensions to Uniform Type Identifiers. That is, I want to find some way of doing this: ".jpg" => "public.jpeg" ".html" => "public.html" ".ttf"=> "public.truetype-font" I've searched on the NSWorkspace docs but couldn't find anything. The closest I could get was: - (...

Get short user name from full name

Anyone know how to get a user's short user name, eg. "johnsmith", given their full name, eg. "John Smith"? Note I'm interested in any user, not the current user, so functions like NSUserName are irrelevant. Why? I am authenticating a username and password using Authorization Services. This allows people to enter either their short name...

Debug 10.6 Project into 10.5?

Hey all, Can I debug a 10.6 project into a 10.5? I have computers at school that are still 10.5 and I need to downgrade it so I can run my program on their computers. Thanks,, Kevin ...

Determine if a network share exists before mounting

I'm working on a tool to automatically mount network volumes based on what wireless network the user is connected to. Mounting the volume is easy: NSURL *volumeURL = /* The URL to the network volume */ // Attempt to mount the volume FSVolumeRefNum volumeRefNum; OSStatus error = FSMountServerVolumeSync((CFURLRef)volumeURL, NULL, NULL, N...

Sample code for creating a NSTextField "label"?

In my desktop Mac OS X app, I'd like to programatically create a NSTextField "label" which has the same behavior and properties as a typical label created in Interface Builder. I usually use (and very much like) IB, but in this case it must be done programatically. Try as I might, I can't seem to find the combination of method calls th...

How can I format time intervals in Cocoa?

I'm looking for a class that formats time intervals like this: 1 hour 3 minutes 2 hours 5 minutes 12 seconds 5 days 2 hours Is there anything built-in or a library that supports this kind of time interval formatting? I thought about doing it myself, but there are all sorts of problems: Localization Non-gregorian calendars. ...

Deciding when nibs should be subdivided in a Cocoa application

Apologies if this has been asked before. I searched and couldn't find it. In my application I have about 10 nib files, most of which hold a single significant view object and a number of subviews/controls. At what point would you consider breaking nibs into pieces? For example in one of my nibs I have an NSCollectionview and the pro...

Clang: what is "Method returns an Objective-C object with a +0 retain count" trying to tell me?

Running a static analysis with clang in both XCode 3.2 and Nikita Zhuk's Analysis Tool I've often come across this pair of warnings: Method returns an Objective-C object with a +0 retain count (non-owning reference) Incorrect decrement of the reference count of an object is not owned at this point by the caller An example of c...

Is there a way for find how many keys are currently in a NSMutableDictionary?

Just curious if there is a way to find the number of keys in a NSMutableDictionary? Also is there a way to access each key in turn and find its value, or do I need to access the data manually via the predefined keys? (i.e.) myTown = [cryo objectForKey: @"town"]; myZip = [cryo objectForKey: @"HT6 4HT"]; myEmail = [cryo objectForKey: ...

Help with Key-Value-Observing.

I need a bit of help with KVO, I'm about half way there. What I'm trying to do is trigger a method when something in an Tree Controller changes. So I 'm using this code to register as a KVO. [theObject addObserver: self forKeyPath: @"myKeyPath" options: NSKeyValueObservingOptionNew context: NUL...